{"id":135,"date":"2005-03-20T21:22:46","date_gmt":"2005-03-20T19:22:46","guid":{"rendered":"http:\/\/blogs.bl0rg.net\/netzstaub\/?p=135"},"modified":"2005-03-20T21:22:46","modified_gmt":"2005-03-20T19:22:46","slug":"rfsid-play-c64-sids-with-an-rfid-reader","status":"publish","type":"post","link":"https:\/\/blogs.bl0rg.net\/netzstaub\/2005\/03\/20\/rfsid-play-c64-sids-with-an-rfid-reader\/","title":{"rendered":"RFSID &#8211; play C64 SIDs with an RFID reader"},"content":{"rendered":"<p>\nDividuum, my flat-mate, has built a very cool RFID application. He stores SID-files (SID is the music format for the C64) on RFID tags. When you put such a tag near to the reader, the music is played on the stereo. He got a RFID reader (ID ISC.PR100) which you can connect to your PC through USB, and has written a library in C to control it. The C library has a very simple interface: it searches for the USB device using libusb, and the application using the library can then send vendor requests to the device (vendor requests are &#8220;USB ioctls on speed&#8221;). The whole functionality of the device can be called using these vendor requests. The C library is used by a Ruby wrapper which has methods for all the commands of the reader. You can read and write the configuration data of the reader, control the LED, write its EEPROM, and, of course, read and write RFID tags, all of this using the OO system of Ruby.\n<\/p>\n<p><!--more--><\/p>\n<p>\nSome RFID tags can store up to 1 kB of data, which is enough to store gzipped SID-files, which are quite small most of the time. In dividuum&#8217;s big collection of 29.000+ SID files, about 400 are small enough to fit on the RFID tags. The code for the RFID playing application itself is quite small, and, because of the Ruby wrapper, very clean. The application itself is 113 lines long, and you can get the complete sourcecode from our public subversion repository at <a href=\"\/\/bl0rg.net\/rfid\/\">svn:\/\/bl0rg.net\/rfid<\/a> .\n<\/p>\n<p>\nAs long as the RFID tag is near the reader, the music is played back. As soon as you remove the RFID tag however, the music stops. A very nice feature is that you can put a stack of tags near the reader, and they will act as a playlist. Remove the playing tag, and the program will play the next SID-File in the stack. <a href=\"\/netzstaub\/files\/rfsid.avi\">Here<\/a> is a video of the SID player.\n<\/p>\n<p>\nAt the Entropia meeting, Blueloop quickly put together a RFID detector using a LED, a piezo-speaker and a wire antenna. <a href=\"\/netzstaub\/files\/rfid-detector.avi\">Here<\/a> are <a href=\"\/netzstaub\/files\/rfid-detector2.avi\">some<\/a> movies of the detector. You can hear the RFID reader reading the tag :).\n<\/p>\n<div>\n<img decoding=\"async\" alt=\"Alt Tag Added during WordPress Conversion\" src=\"\/netzstaub\/images\/rfid-detector.jpg\" \/><\/div>\n<p>I won&#8217;t post a lot of technical details in this post, as the application is best explained by reading the sourcecode \ud83d\ude42 Believe me, it is very clear and straightforward. I&#8217;d like to point out the libusb, which allows you to do crossplatform, userland USB development without much hassle. I used the libusb USB communication code for a few devices, including crypto-communication hardware, a USB analyzer and mobile phones, and it is very nice to have the same code work on most current unix platforms. Check it out at <a href=\"http:\/\/libusb.sourceforge.net\/\">libusb<\/a>. In order to have a few lines of code in this post though, here is the ruby program dividuum used to test writing to RFID tags:\n<\/p>\n<p><pre>#!\/usr\/bin\/env ruby\nrequire 'rfid'\n\ntext  = ARGV.join(' ') + \"\\x00\"\ntext += \"\\x00\" * (4 - text.size % 4)\n\nRFID::Device.new(0) do |rfid|\n    loop do \n        rfid.readSerials.each do |label|\n            if rfid.write(label.snr, text) \n                puts \"Wrote to #{label.snrHex}\"\n            end\n        end\n    end\nend\n<\/pre>\n<div>\n<\/div>\n<div>\nThe first lines combine all the text given on the command line, and pad the data with &#8216;0&#8217; bytes to a 4 byte boundary. In the next line, a new object corresponding to a RFID reader is created using &#8220;RFID::Device.new&#8221;, and each tag in reach is written with the text given on the command line. &#8220;readSerials&#8221; returns an array of label objects, and these are written using the rfid method &#8220;write&#8221;. Very simple indeed. And here is the reading counterpart:\n<\/div>\n<pre>#!\/usr\/bin\/env ruby\nrequire 'rfid'\n\nRFID::Device.new(0) do |rfid|\n    loop do \n        rfid.readSerials.each do |label|\n            data, blocksRead, blockSize = rfid.read(label.snr, 0, 10)\n            puts \"Read from #{label.snrHex}: #{data}\" if data\n        end\n    end\nend\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Dividuum, my flat-mate, has built a very cool RFID application. He stores SID-files (SID is the music format for the C64) on RFID tags. When you put such a tag near to the reader, the music is played on the &hellip; <a href=\"https:\/\/blogs.bl0rg.net\/netzstaub\/2005\/03\/20\/rfsid-play-c64-sids-with-an-rfid-reader\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,19],"tags":[],"class_list":["post-135","post","type-post","status-publish","format-standard","hentry","category-bastelstaub","category-english"],"_links":{"self":[{"href":"https:\/\/blogs.bl0rg.net\/netzstaub\/wp-json\/wp\/v2\/posts\/135","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blogs.bl0rg.net\/netzstaub\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.bl0rg.net\/netzstaub\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.bl0rg.net\/netzstaub\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.bl0rg.net\/netzstaub\/wp-json\/wp\/v2\/comments?post=135"}],"version-history":[{"count":0,"href":"https:\/\/blogs.bl0rg.net\/netzstaub\/wp-json\/wp\/v2\/posts\/135\/revisions"}],"wp:attachment":[{"href":"https:\/\/blogs.bl0rg.net\/netzstaub\/wp-json\/wp\/v2\/media?parent=135"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.bl0rg.net\/netzstaub\/wp-json\/wp\/v2\/categories?post=135"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.bl0rg.net\/netzstaub\/wp-json\/wp\/v2\/tags?post=135"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}