chris12892
Posts: 3
Joined: Wed Aug 19, 2015 12:31 am

Bizzare issues with serial port(s)

Wed Aug 19, 2015 1:28 am

Hi,

I have a Raspberry Pi 2 running Debian Jessie upgraded using the apt-get dist-upgrade method. Nothing has been done to the pi other than installing Jessie and running rpi-update. The unit has a 2.1A power supply.

I'm having a bizarre issue with both the onboard serial ports as well as FTDI chipsets and also a Prolific chipset. The ACM driver for the Arduno Uno works (mostly?) fine. I did disable the terminal on the onboard serial port before testing (using raspi-config).

Basically if I connect one of the offending chipsets (or use the onboard serial port) and then use stty to set the baud rate, then try to cat /dev/ttyUSB0 > /home/pi/log.txt, I'll either get 0 bytes in the log, or the log will contain lots of corrupt data (data out of order from how it was sent). Behavior is extremely inconsistent, so it's a little hard for me to provide much more detail then that.

Any ideas on what may be going on here?

Thanks

chris12892
Posts: 3
Joined: Wed Aug 19, 2015 12:31 am

Re: Bizzare issues with serial port(s)

Wed Aug 19, 2015 6:54 am

Just an update to this...

After some hours, I found that this bizarre behavior isn't limited to the PI, it's happening on desktop Ubuntu too. it seems like bytes are getting dropped or something. But the question still stands, I suppose. Has anyone had any luck reading from an FTDI USB to serial bridge with the Raspberry PI using the C++ termios API?

User avatar
Douglas6
Posts: 5120
Joined: Sat Mar 16, 2013 5:34 am
Location: Chicago, USA

Re: Bizzare issues with serial port(s)

Wed Aug 19, 2015 3:08 pm

The onboard UART (TX/RX pins) will appear at /dev/tty0, I believe.

scotty101
Posts: 4433
Joined: Fri Jun 08, 2012 6:03 pm

Re: Bizzare issues with serial port(s)

Wed Aug 19, 2015 3:24 pm

Douglas6 wrote:The onboard UART (TX/RX pins) will appear at /dev/tty0, I believe.
Nope. /dev/ttyAMA0

Source: http://elinux.org/RPi_Serial_Connection ... erial_port
Electronic and Computer Engineer
Pi Interests: Home Automation, IOT, Python and Tkinter

User avatar
Douglas6
Posts: 5120
Joined: Sat Mar 16, 2013 5:34 am
Location: Chicago, USA

Re: Bizzare issues with serial port(s)

Wed Aug 19, 2015 3:26 pm

scotty101 wrote:
Douglas6 wrote:The onboard UART (TX/RX pins) will appear at /dev/tty0, I believe.
Nope. /dev/ttyAMA0
Grrrr, of course, sorry.

chris12892
Posts: 3
Joined: Wed Aug 19, 2015 12:31 am

Re: Bizzare issues with serial port(s)

Thu Aug 20, 2015 9:00 am

Just an update....

It appears as though I managed to fix this. It ended up being some combination of flags that allowed it to work. For anyone else having odd serial issues, here's the code I used to start a serial port connection for nonblocking reads.

Code: Select all

	struct termios tio;

	// Serial config
	memset(&tio, 0, sizeof(tio));

	tio.c_iflag = 0;
	tio.c_oflag = 0;
	tio.c_cflag = CS8 | CREAD | CLOCAL;
	tio.c_lflag = 0;
	tio.c_cc[VMIN] = 0;
	tio.c_cc[VTIME] = 0;

	// Open the device
	tty_fd = open(path.c_str(), O_RDWR | O_NOCTTY | O_NDELAY);
	
	// Check if the port didn't open correctly
	if (tty_fd==-1)
	{
		return 0;
	}

	// 115200
	if (cfsetospeed(&tio, B115200) || cfsetispeed(&tio, B115200))
	{
		return 0;
	}

	cfmakeraw(&tio);
	tcflush(tty_fd, TCIFLUSH);
	tcsetattr(tty_fd, TCSANOW, &tio);
	

User avatar
KLL
Posts: 1453
Joined: Wed Jan 09, 2013 3:05 pm
Location: thailand

Re: Bizzare issues with serial port(s)

Thu Aug 20, 2015 12:16 pm

hi CHRIS,
last 2 days i am investigating a other funny serial problem
-a- i have a arduino UNO
- connected and powered by RPI - USB - see 5.07V at arduino
- with good code what allow me to see ( in this respect )
- - a reboot
- - some slow diag msg show that all running well
- - a input of a character ( serial menu.. project ) has a clear response.

-b- i had a full updated raspbian, but to recheck burned raspbian 05052015 today again.

-c- i used the serial port software
-c1 ARDUINO IDE 101 serial monitor
-c2 screen
-c3 minicom

no matter what system and what software i used,
the arduino reboots at connection OR NOT.
p.s. on WIN7 pc its clear that the arduino IDE serial monitor causes a reboot
but the HTERM with DTR OFF can connect without reboot! ( both well defined )
all details see http://kll.engineering-news.org/kllfusi ... icle_id=97

can you possibly confirm with your above code if arduino UNO is rebooting on connection?

Return to “Troubleshooting”