Community
cancel
Showing results for 
Search instead for 
Did you mean: 
idata
Community Manager
1,572 Views

Issue to write on serial

I'm try to use the USB serial port, but I have some issue to send data from PC to Edison using mraa

I init the port in follow way:

uart = mraa_uart_init_raw("/dev/ttyGS0");

mraa_uart_set_baudrate(uart, 9600);

mraa_uart_set_mode(uart, 8,MRAA_UART_PARITY_NONE , 1);

mraa_uart_set_flowcontrol(uart, 0, 0);

mraa_uart_set_timeout(uart, 1, 1, 1);

and after in a function I check the availabily of new data and I read the bytes one by one:

// while data availablewhile( mraa_uart_data_available(uart,1)){

// read 1 byte from serialnumread = mraa_uart_read(uart, data, 1)

// if something read

if (numread > 0)

{

...

}

}

This strategy is because I don't want block the program on the reading and get bytes only when data is available.

But, when I send the data from PC (using a serial terminal like Arduino monitor or a C# program create by myself), the reading not work correctly: most part of time don't read anything, sometime get 1 or 2 bytes.

The communication is ok, because if I send data from Edison to PC it works great. Furthermore I used same strategy to read and write data from a sensor on HW serial on Edison (pin 0 and 1) and worked well.

Only problem when I try to send data from PC over USB. What could be the issue?

0 Kudos
5 Replies
idata
Community Manager
65 Views

Hi Ulixxes,

 

 

Thanks for contacting us,

 

 

I believe ttyGS0 is not available on mraa. As you can see in this link http://iotdk.intel.com/docs/master/mraa/edison.html http://iotdk.intel.com/docs/master/mraa/edison.html, the available UART interface is on /dev/ttyMFD1, so you might test using an FTDI cable connecting to TX (1) and RX (0) and then use a terminal to see the UART communication.

 

 

On the other hand, I would like to know how you are sending data from the Edison to PC.

 

I'll be waiting your reply in order to help you.

 

 

Regards,

 

-Yermi

 

idata
Community Manager
65 Views

Hi Ulixxes,

 

 

I would like to know if you have any updates. Were you able to send data from the PC to Edison successfully?

 

 

Regards,

 

-Yermi

 

idata
Community Manager
65 Views

Unfortunately no.

Anyway I can't use the pin 0/1 serial because is busy for a serial sensor.

I'm surprised that I can't use the USB serial as communication to PC..

Anyway, about your previous question to send from Edison to PC with the USB serial port looks to work:

I'm using Eclipse tool, but if I use the Arduino IDE isn't the same than use Serial.print()?????

here the extract of init port:

uart = mraa_uart_init_raw("/dev/ttyGS0");mraa_uart_set_baudrate(uart, 9600);mraa_uart_set_mode(uart, 8,MRAA_UART_PARITY_NONE , 1);

and here of send serial:

// send datareturn mraa_uart_write(uart, data, strlen(data));
idata
Community Manager
65 Views

Hi Ulixxes,

 

 

Thanks for all the information that you have shared.

 

 

I made some tests using /dev/ttyGS0 port, and I'm having the same issue, I'm able to send data from the Edison to the PC, but vice-versa, I got the same behavior, sometimes the data is lost and others it is read. So, let me investigate a little bit more in order to help you with that.

 

 

I'll appreciate your patience, also if you have any update, let me know please.

 

 

Regards,

 

Yermi.

 

Brendan_L_Intel
Employee
65 Views

you'll need to kill clloader, there's a systemd service called galileo-target or similar running and use systemctl stop and systemctl disable . That should enable you to have two way communication.

Reply