facing issues with hardware UART port in raspberry

4 views
Skip to first unread message

Abu_Abdullah

unread,
Mar 4, 2017, 12:13:40 PM3/4/17
to SerialPundit
Hi,

I'm trying to connect to external controller via the hardware UART pins in raspberry. the serial receives the data in broken way in onNewSerialDataAvailable(byte[] inBuf).

How can i troubleshoot this issue. I'm using the standard code below:

try
{
   
serial = new SerialComManager();
   

   
String PORT = "/dev/ttyS0";
// "/dev/ttyUSB0"  via UART1:USB      

   comPortHandle = serial.openComPort(PORT, true, true, true);
   
serial.configureComPortData(comPortHandle, DATABITS.DB_8, STOPBITS.SB_1, PARITY.P_NONE, BAUDRATE.B115200, 0);
   
serial.configureComPortControl(comPortHandle, FLOWCONTROL.NONE, 'x', 'x', false, false);

   
// register data listener for this port
   serial.registerDataListener(comPortHandle, this);
}
catch (Exception e)
{
   e
.printStackTrace();
   
if(comPortHandle != -1)
     
try {serial.closeComPort(comPortHandle);} catch (Exception e1) {}
   
return;
}


Abu_Abdullah

unread,
Mar 4, 2017, 12:15:47 PM3/4/17
to SerialPundit
listening to the serial via USB (USB-UART from both sides raspberry and the external controller) is working fine but not working if using the hardware UART pins in both sides.

Rishi Gupta

unread,
Mar 5, 2017, 12:31:54 AM3/5/17
to SerialPundit
May you please share exact hardware details like pin number of rpi, rpi2 or rpi3, connection details like rpi --> ft233 -> which controller etc. so that I can understand further. Also how one end sends data to other.

Abu_Abdullah

unread,
Mar 5, 2017, 8:39:13 AM3/5/17
to SerialPundit


sure,

Raspberry Pi 3, GPIO 14 (TX) & 15 (RX)
those are the UART pins, it is connected to UART2 - RMRC Seriously Dodo Flight Controller 

attached are the layout for both

in raspberry pi 3, the same pins are used for both bluetooth and serial:
/dev/ttyAMA0 (hardware high performance UART)
/dev/ttyS0 (software low performance UART)

ttyS0 is the default for serial but can be switched with the hardware. i tried both of them. for switching i was following:
http://spellfoundry.com/2016/05/29/configuring-gpio-serial-port-raspbian-jessie-including-pi-3/

the UART-USB that is working is connected in the controller to the USB which is connected internally to UART1 and to one of raspi usb ports.





Abu_Abdullah

unread,
Mar 5, 2017, 10:23:22 AM3/5/17
to SerialPundit
there is a possibility that the issue is from the controller firmware and not raspi or serialpundit. I will check this

Abu_Abdullah

unread,
Mar 5, 2017, 1:15:40 PM3/5/17
to SerialPundit
ok, after some troubleshooting, the serial stream is received in chunks of 8 or 5 bytes and not in a clean way as in the USB-UART. i modified my code so that it will merge bytes together.

I'm not sure if this is an issue in the controller or something else but this workaround is enough at this stage. thanks

Reply all
Reply to author
Forward
0 new messages