Page 1 of 1

USB to Serial rs232 / rs485 problems

Posted: Mon Jul 23, 2012 11:49 am
by chrischdi
Hey guys,

I got problems to get my usb to serial adapter working with my Raspberry.

First of all, it is recognized without problems by the kernel. lsusb shows the device like it's needed.
I also got a /dev/ttyUSB0.

I also power it (The usb adapter and raspberry) by a USB-hub with extra power. I also powered the Raspberry with a extra power cable (without usb-hub) and attached the usb serial adapter directly to the Raspberry and with the USB-Hub.

Now to my Problem:
If i even try a "cat /dev/ttyUSB0" the rasperry hangs and I have to power it off and on again to get it back running.

I tried different distris (Raspian and both Debian versions) with the same result.

The logfiles don't show anything to me. I tried to watch them live while using the cat command but there was nothing written to them.

Greetz Chrischdi

Re: USB to Serial rs232 / rs485 problems

Posted: Tue Jul 24, 2012 6:51 pm
by FruityPenguin
Hi,

can you post the relevant lines from lsusb and dmesg?
It would be useful to know the exact type of the adapter you're using.

There were some previous reports about problems with serial-to-USB adapters:
http://www.raspberrypi.org/phpBB3/viewt ... 28&t=10330
http://www.raspberrypi.org/phpBB3/viewt ... =44&t=8010

Re: USB to Serial rs232 / rs485 problems

Posted: Wed Jul 25, 2012 7:23 am
by chrischdi
Thanks for your answer.
I think I will order another USB Serial Converter with a newer ftdi chip, cause the FT232BM is also not working for other users.

System logs:

dmesg:

Code: Select all

[    5.222759] usb 1-1: new high speed USB device number 2 using dwc_otg
[    5.443395] usb 1-1: New USB device found, idVendor=0424, idProduct=9512
[    5.452589] usb 1-1: New USB device strings: Mfr=0, Product=0, SerialNumber=0
[    5.464970] hub 1-1:1.0: USB hub found
[    5.472781] hub 1-1:1.0: 3 ports detected
[    5.752988] usb 1-1.1: new high speed USB device number 3 using dwc_otg
[    5.863350] usb 1-1.1: New USB device found, idVendor=0424, idProduct=ec00
[    5.872596] usb 1-1.1: New USB device strings: Mfr=0, Product=0, SerialNumber=0
[    5.887147] smsc95xx v1.0.4
[    5.958765] smsc95xx 1-1.1:1.0: eth0: register 'smsc95xx' at usb-bcm2708_usb-1.1, smsc95xx USB 2.0 Ethernet, b8:27:eb:09:cb:3e
[    6.052929] usb 1-1.3: new high speed USB device number 4 using dwc_otg
[    6.166607] usb 1-1.3: New USB device found, idVendor=05e3, idProduct=0608
[    6.176453] usb 1-1.3: New USB device strings: Mfr=0, Product=1, SerialNumber=0
[    6.186472] usb 1-1.3: Product: USB2.0 Hub
[    6.198097] hub 1-1.3:1.0: USB hub found
[    6.207329] hub 1-1.3:1.0: 4 ports detected
[    6.494678] usb 1-1.3.4: new full speed USB device number 5 using dwc_otg
[    6.604644] usb 1-1.3.4: New USB device found, idVendor=0403, idProduct=6001
[    6.614267] usb 1-1.3.4: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[    6.626914] usb 1-1.3.4: Product: USB <-> Serial
[    6.634447] usb 1-1.3.4: Manufacturer: FTDI
[    8.952879] EXT4-fs (mmcblk0p2): ext4_orphan_cleanup: deleting unreferenced inode 65650
[    8.953399] EXT4-fs (mmcblk0p2): ext4_orphan_cleanup: deleting unreferenced inode 65651
[    8.953593] EXT4-fs (mmcblk0p2): 2 orphan inodes deleted
[    8.961292] EXT4-fs (mmcblk0p2): recovery complete
[    9.003547] EXT4-fs (mmcblk0p2): mounted filesystem with ordered data mode. Opts: (null)
[    9.016564] VFS: Mounted root (ext4 filesystem) on device 179:2.
[    9.026547] Freeing init memory: 200K
[   11.701073] usbcore: registered new interface driver usbserial
[   11.798268] USB Serial support registered for generic
[   11.939798] usbcore: registered new interface driver usbserial_generic
[   12.129929] usbserial: USB Serial Driver core
[   12.379503] USB Serial support registered for FTDI USB Serial Device
[   12.713565] ftdi_sio 1-1.3.4:1.0: FTDI USB Serial Device converter detected
[   12.938320] usb 1-1.3.4: Detected FT232BM
[   13.007609] usb 1-1.3.4: Number of endpoints 2
[   13.059598] usb 1-1.3.4: Endpoint 1 MaxPacketSize 64
[   13.122770] usb 1-1.3.4: Endpoint 2 MaxPacketSize 64
[   13.130235] usb 1-1.3.4: Setting MaxPacketSize 64
[   13.305268] usb 1-1.3.4: FTDI USB Serial Device converter now attached to ttyUSB0
[   13.411096] usbcore: registered new interface driver ftdi_sio
[   13.495650] ftdi_sio: v1.6.0:USB FTDI Serial Converters Driver
[   17.386338] EXT4-fs (mmcblk0p2): re-mounted. Opts: (null)
[   17.755442] ### snd_bcm2835_alsa_probe c05d07a0 ############### PROBING FOR bcm2835 ALSA device (0):(1) ###############
[   17.774076] Creating card...
[   17.779325] Creating device/chip ..
[   17.785834] Adding controls ..
[   17.791080] Registering card ....
[   17.802987] bcm2835 ALSA CARD CREATED!
[   17.809934] ### BCM2835 ALSA driver init OK ###
[   24.843433] smsc95xx 1-1.1:1.0: eth0: link up, 100Mbps, full-duplex, lpa 0x45E1
[   29.137313] Adding 102396k swap on /var/swap.  Priority:-1 extents:1 across:102396k SS
lsusb -v (Only part of the adapter):

Code: Select all

Bus 001 Device 005: ID 0403:6001 Future Technology Devices International, Ltd FT232 USB-Serial (UART) IC
Couldn't open device, some information will be missing
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               1.10
  bDeviceClass            0 (Defined at Interface level)
  bDeviceSubClass         0
  bDeviceProtocol         0
  bMaxPacketSize0         8
  idVendor           0x0403 Future Technology Devices International, Ltd
  idProduct          0x6001 FT232 USB-Serial (UART) IC
  bcdDevice            4.00
  iManufacturer           1
  iProduct                2
  iSerial                 0
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength           32
    bNumInterfaces          1
    bConfigurationValue     1
    iConfiguration          0
    bmAttributes         0x80
      (Bus Powered)
    MaxPower               90mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           2
      bInterfaceClass       255 Vendor Specific Class
      bInterfaceSubClass    255 Vendor Specific Subclass
      bInterfaceProtocol    255 Vendor Specific Protocol
      iInterface              2
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval               0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x02  EP 2 OUT
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval               0

Re: USB to Serial rs232 / rs485 problems

Posted: Fri Aug 31, 2012 12:22 pm
by elvikingo
Hi chrischdi,
Have you found a solution ?
I have the same problem, with a RS485/usb converter. When plugged, the raspberry Pi freezes.
I use the raspbian image.
Does anyone sucessfully used a RS485/usb converter ?
Cheers

Re: USB to Serial rs232 / rs485 problems

Posted: Thu Sep 06, 2012 9:11 am
by elvikingo
Hi,

I ordered a new USB/rs485 converter cable based on the FT232R ship (USB-RS485-WE-1800-BT).
It is now working !

My older cable (non-working) was based on the LINX SDM-USB-QS1-S module.

Hope this helps.

Re: USB to Serial rs232 / rs485 problems

Posted: Sun Nov 18, 2012 6:04 am
by jpmathew
I am a beginner to Raspberry Pi and RS485. Could you give a simple C code to read data from a RS485 slave using FTDI RS485 cable. Which Driver should I use for Raspberry Pi?
Thanks
Joseph Mathew

Re: USB to Serial rs232 / rs485 problems

Posted: Mon Nov 19, 2012 8:50 am
by elvikingo
Hi,
You can use this bit of code to receive data from the usb/rs485 adapter.
Cheers

Code: Select all



#include <unistd.h>
#include <stdio.h>
#include <math.h>
#include <string.h>

#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <termios.h>
#include <stdint.h>


#define SERIAL_BUF_SIZE (1024)
#define MSG_BUF_SIZE (128)


int initSerialConnectionAHRS(char *ttyPath){

	int tty_fd;

	struct termios tio;
	
	memset(&tio,0,sizeof(tio));
	tio.c_iflag=0;
	tio.c_oflag=0;
	tio.c_cflag=CS8|CREAD|CLOCAL|CSTOPB|PARENB;           // 8n1, see termios.h for more information
	tio.c_lflag=0;
	tio.c_cc[VMIN]=1;
	tio.c_cc[VTIME]=5;

	tty_fd = open(ttyPath, O_RDONLY | O_NONBLOCK);      
	cfsetospeed(&tio,B115200);            // 115200 baud
	cfsetispeed(&tio,B115200);            // 115200 baud

	tcsetattr(tty_fd,TCSANOW,&tio);

	return(tty_fd);
}


void* runSerialAHRS()
{
	char *ttyPath = "/dev/serial/by-id/usb-FTDI_USB-RS485_Cable_FTV8X5A2-if00-port0"; //"/dev/serial/by-id/usb-Linx_Technologies_LINX_SDM-USB-QS-S-if00-port0"; // "/dev/ttyUSB0"
	int tty_fd;
	int j=0;
	
	uint8_t c[SERIAL_BUF_SIZE];
	int red;
	
	//Save terminal configuration
	struct termios oldtio;
	tcgetattr(STDOUT_FILENO, &oldtio);
	
	
	tty_fd = initSerialConnectionAHRS(ttyPath);
		
	if(tty_fd == -1)
		printf("Failed to open %s.\n", ttyPath);
	else
		printf("AHRS is running...\n");
	
	while (1)
	{
		red = read(tty_fd, &c, SERIAL_BUF_SIZE);
		
		//then process received data
	}

	//Close connections
	close(tty_fd);
	
	//back to initial terminal configuration
	tcsetattr(STDOUT_FILENO,TCSANOW,&oldtio);
	tcsetattr(STDOUT_FILENO, TCSAFLUSH, &oldtio);
}

int main(){
	
		runSerialAHRS();
		return(0);
}


Re: USB to Serial rs232 / rs485 problems

Posted: Thu Jan 02, 2014 8:22 pm
by leopheard
I'm not sure if I'm having the same issue, but I'm trying to configure CUPS via my RPi into an HP Laserjet 6MP using a parallell to USB connector.

One problem I've found and although common, is easy to overlook - I've just realised the cable connection doesn't show up under lsusb as I was plugging the printer in via a 4 port hub, and now the following cable is shown:

ID 067b:2305 Prolific Technology, Inc. PL2305 Parallel Port IEEE-1284 controller

Just in the event anyone else is having problems with their RP or CUPS detecting their printer. Still not got CUPS to print successfully mind.