In one of my personal projects, I needed to connect and use a USB to RS232 (Serial) converter on my D-Link DNS-323. Weird requirements, I know. Anyway… 😐
Plenty of these converters exist out there, but I choose to go for a CP2102:
Innocently, I first tried to compile the code source of this module which can be found on the following page:
http://www.silabs.com/products/mcu/Pages/USBtoUARTBridgeVCPDrivers.aspx
After a few painful and unsuccessful tries, I decided to look around for the already-compiled module. 😉
While wondering why I didn’t think of that before, I used the instructions below to install the required modules on my NAS:
cd /mnt/HD_a2/ffp/lib/ mkdir modules mkdir modules/2.6.12.6-arm1 cd modules/2.6.12.6-arm1 wget http://dev.skcserver.de/dns323/modules_v1.03/kernel/drivers/usb/serial/usbserial.ko wget http://dev.skcserver.de/dns323/modules_v1.03/kernel/drivers/usb/serial/cp2101.ko chmod 755 usbserial.ko chmod 755 cp2101.ko
Once the modules are installed, the next step is to initialize them.
I wrote the following script for this purpose so you can execute it anytime you need it:
#!/bin/sh insmod /ffp/lib/modules/2.6.12.6-arm1/usbserial.ko insmod /ffp/lib/modules/2.6.12.6-arm1/cp2101.ko mknod /dev/ttyUSB0 c 188 0 chmod 0666 /dev/ttyUSB0
At this point in time, you should have your module initialized on your D-Link DNS-323.
You can check the kernel ring buffer using the dmesg command to verify it loaded properly.
This is a snapshot of what I have in my kernel ring buffer after I ran the script above:
usbcore: registered new driver usbserial drivers/usb/serial/usb-serial.c: USB Serial support registered for Generic usbcore: registered new driver usbserial_generic drivers/usb/serial/usb-serial.c: USB Serial Driver core v2.0 drivers/usb/serial/usb-serial.c: USB Serial support registered for CP2101 CP2101 1-1:1.0: CP2101 converter detected usb 1-1: reset full speed USB device using ehci_platform and address 5 usb 1-1: CP2101 converter now attached to ttyUSB0 usbcore: registered new driver CP2101 drivers/usb/serial/cp2101.c: Silicon Labs CP2101/CP2102 RS232 serial adaptor driver v0.04
Finally, you can test the communication with your USB to RS232 converter by connecting a LED between the RXD and 3V outputs and running the following script:
#!/bin/sh while [ true ] do echo "hello world!!!" > /dev/ttyUSB0 echo "sent" sleep 1 done
If you see the LED blinking, it means you succeed! 😀
#1 by MR on 24 Dec 2012 - 10:24
Hi,
Where did you bought the converter? (silabs only sells the chip and a expensive evaluation kit, as i understand reading their website)?
tia
#2 by smoreau on 24 Dec 2012 - 13:09
I bought it on ebay for £5.60 (postage included).
You can find a few there: http://www.ebay.co.uk/sch/i.html?LH_BIN=1&_from=R40&_nkw=cp2102&_sop=15&_clu=2&_fcid=3&_localstpos&_stpos&gbr=1
#3 by MR on 24 Dec 2012 - 13:38
thanks a lot.