Community
cancel
Showing results for 
Search instead for 
Did you mean: 
blesh
New Contributor I
2,225 Views

PROBLEM:Edison's UART behavior is diffrent when connected to different circuits.

Hallo friends.

Me again and my UART problems.

I wrote a simple program to transmit a massage, every 3 seconds, from my Edison via UART using mraalib.

First I tried to send from my Edison to my computer using TTL to USB chip.

When I'm connecting pins 0,1 & ground to a CP2102 USB to TTL and the CP2102 to my pc, and open serial terminal at my pc (screen /dev/ttyUSB0 38400 ),

the massages is received and printed perfectly .

Photo of the circuit:

http://www.siz.co.il/my.php?i=2mmmyzzzutmz.jpg http://www.siz.co.il/my.php?i=2mmmyzzzutmz.jpg

ScreenShot of screen's output.

http://www.siz.co.il/my.php?i=mgwjqknlym1f.png Siz - העלאת תמונות | פתיחת גלריות

The Problem:

After checking with single Edison, I want to communicate between two of them, connecting then via UART. 

When I connect pins 0,1 & ground of my Edison# 1, to pins 1,0 & ground of my Edison# 2 (rx# 1->tx# 2, tx# 1->rx# 2), the # 2 Edison get something a bit different.

I use mraa's read function constantly (polling), waiting for information to arrive (I can use data_available function before, but the results are the same).

Then I print to screen the Decimal value of every byte I get.

The result is different then the first circuit.

Photo of the circuit:

http://www.siz.co.il/my.php?i=qnzzwyqzzgy5.jpg http://www.siz.co.il/my.php?i=qnzzwyqzzgy5.jpg

the printed received data is this:

ScreenShot of output:

http://www.siz.co.il/my.php?i=mjamwqdzzhoz.png Siz - העלאת תמונות | פתיחת גלריות

As you can see, Edison# 2 (receiver) get a lot of single Bytes with the value 10 (0b00001010, ASCII '\n') . it is received at the moment my first massage is sent from Edison# 1 (transmitter).

to be accurate, the amount of Decimal 10s I receive is few thousands (change every execution, but repeat itself - 5292 , 5300 or 7973 times).

After receiving all the 10's, Edison# 2 receive perfectly the 2nd massage sent from Edison# 1, and then 3rd massage padded with decimal 0 before the massage. 4th massage is also OK accept for the added 0, and so on with 5,6, .....

between every two massages, a single byte with Decimal 10 value is received at Edison# 2.

When I try to send the massage without '\n' between Edisons, the receiving Edison doesn't receive anything. (at the first circuit Edison -> PC the massage received perfectly, and it is printed without new line of course).

My uart's initiation Function (at both edisons at circuit 2, and at the single edison of circuit 1):

int init_modem(){

if( (uart = mraa_uart_init(0)) == NULL ){

exit(UART_ERROR);

}

if ( mraa_uart_set_baudrate(uart, UART_BOUD_RATE)!=MRAA_SUCCESS) {

exit(UART_ERROR);

} //set uart boud rate [bps]

if ( mraa_uart_set_mode(uart, 8,MRAA_UART_PARITY_NONE , 1)!=MRAA_SUCCESS) {

}

mraa_uart_set_flowcontrol(uart, 0, 0);

return 1;

}

Full code is:

port5_trans.c (for both circuit 1,2)

https://github.com/barlesh/ISG/blob/master/UART/init_UART/port5_trans.c https://github.com/barlesh/ISG/blob/master/UART/init_UART/port5_trans.c

port5_trans.h

https://github.com/barlesh/ISG/blob/master/UART/init_UART/port5_trans.h ISG/port5_trans.h at master · barlesh/ISG · GitHub

port5_rec.c (circuit 2).

https://github.com/barlesh/ISG/blob/master/UART/init_UART/port5_rec.c ISG/port5_rec.c at master · barlesh/ISG · GitHub

port5_rec.h

https://github.com/barlesh/ISG/blob/master/UART/init_UART/port5_rec.h ISG/port5_rec.h at master · barlesh/ISG · GitHub

Both The Edisons ware flashed recently (configure_edison --version output is 159).

What can be the problem? What am I missing here?

Why the results are perfect while using the USB-TTL chip but getting crazy when connecting directly?

Thank you very much for you time & help. please let me know if I missed important information.

Bar

12 Replies
Pedro_M_Intel
Employee
129 Views

Hello barlesh,

I was able to send data through UART by performing a quick test using https://github.com/intel-iot-devkit/mraa/blob/master/examples/uart.c this example on the first Edison and opening the second Edison's serial port. Can you try something like this?

Have you tried testing it directly on Linux to see if the code is the one causing issues? Did you make sure that the settings for both boards are the same (baud rate, etc.)?

Peter.

blesh
New Contributor I
129 Views

Hallo Peter.

Thank you for the fast reply.

What do you mean by "opening second Edison's port"?

How did you wire Edisons to each other? How did you "see" incoming data? with "screen" (or any other serial app)?

What do you mean by "testing it directly on Linux"?

as you saw at my quastion, the two Edisons initiated mraa_context_uart with the same code, so the settings are identical.

I should mention that my final goal is to make the Edison to be the "brain" of Device I got, which communicate (get commands and return answers) over UART.

after writing the simple program (that worked - circuit 1), I tried to send it some instructions, but nothing happen.

So I thought that maybe the reason if the difference between circuits (I wire the device directly to my Edison Rx->Tx, Tx->Rx, gnd->gnd, unlike circuit 1 with the TTL-USB convertor), and as you can see, something isn't exactly proper.

Thanks

Bar

Pedro_M_Intel
Employee
129 Views

What I meant by opening the second Edison's port is that I set it to read everything I received, I did it with the command 'cat /dev/ttyMFD1' directly from Linux.

For wiring, I used the same configuration as you. And as I mentioned above, I saw all the incoming data with the command 'cat /dev/ttyMFD1'.

I meant, you could set your second Edison to read using your code and then manually send the data. You can do this from Linux with the command 'echo YOURDATA > /dev/ttyMFD1'. That way you can test if you are receiving the data correctly. This also applies the other way around, you can set the first Edison to send data with your code and set the second Edison to manually read it from Linux. This way you can check if the data sent is in fact what you need.

I believe the issue can be found in the code, probably the reading part since you mentioned that the writing part was functional. I suggest you to do these tests and identify where the issue is.

Peter.

blesh
New Contributor I
129 Views

Hi Peter

I've tried to check if data is written at '/dev/ttyMFD1', but nothing is going on there.

when trying to receive with 'cat /dev/ttyMFD1' the terminal is waiting and nothing happens.

when trying to send with 'echo YOURDATA > /dev/ttyMFD1' the receiving edison doesn't get anything.

I dont know if that didn't worked out because of a communication problem, because when trying with the simple mraa programs, I get some of my information at the receiving side (only with 0x0A terminated buffers! ), so something passed. (by the way, which terminal software such as 'screen' or 'minicom' is recommended for the edison?).

I should get an access for a Multimeter and start checking what is really going on there....

Pedro_M_Intel
Employee
129 Views

Your description does sound pretty weird; I also believe it would be great if you could get access to a device that lets you check what's really going on. If you had access to a logic analyzer it would be great.

Peter.

blesh
New Contributor I
129 Views

I'm not at home for some time so I can't upload the scope's images, but I found out that when only one wire (TX - > rx) is connected communication works perfectly. When plugging the other direction the TX line start to transmit packets non stop (trash). It happens at run time (it works OK with one wire and running the program and at the moment I plug the second one it start to get crazy. I'll upload the screen shots later.

Due to a deadline I switched to use the type A USB connector + cp2102 with termios library and it works perfectly. Just need to buy another 30 of this little guys.

Hope I`ll find solution to my TTL uart problem so I can publish it here.

Bar

blesh
New Contributor I
129 Views

http://www.siz.co.il/my.php?i=3mmky3wmdmqm.jpg http://www.siz.co.il/my.php?i=3mmky3wmdmqm.jpg

http://www.siz.co.il/my.php?i=gz1mdz3ylmhm.jpg http://www.siz.co.il/my.php?i=gz1mdz3ylmhm.jpg

Yellow Edison1 TX

Green Edison2 TX

First image when only TX is wired (for some reason the rx isn't flat 0.

Seconed when rx is connected.

blesh
New Contributor I
129 Views

I've tried to connect my edison to my modem, changed J9 jumper location (I think it sets the voltage of TTL to 3.3V, same as the modem's).

now, information get to the modem (it sends it via RF or PLC, and I get it on another receiving modem), but, when I sent byte with value 10 (0x0A) I get wrong Date on the other side. I don't think its a modem's problem, because it jest get raw data and broadcast it.

Sounds like some kind of a canonical mode (like at termios) that mraa is implementing.... rings a bell to someone?

tnx

Bar

Carlos_M_Intel
Employee
129 Views

Hi barlesh,

Have you been able to send messages through the UART? Which image version do you have?

Have you done changes in your image?

Regards,

Charlie

blesh
New Contributor I
129 Views

Image version 159

No changes but installing nano and erlang vm.

I succeeded to send massages with the CP2102 converter, but not with direct connection of pins 0,1

blesh
New Contributor I
129 Views

So, I dont have a solution for my work with mraa (I've posted a question at their forum on github : https://github.com/intel-iot-devkit/mraa/issues/350# issuecomment-153482438 "canonical mode" for uart (on Intel Edison) · Issue # 350 · intel-iot-devkit/mraa · GitHub), but, I was able to communicate the way I wanted between two edison & between my edison and my modem, by configuring pins 0,1 to behave as uart using linux commands (used ), and then handling it just like any other serial connection, using termios lib (much flexible).

so if libmraa (which is implemented using termios!) dont behave the way you expect it, use termios. it is more complicated but gives you more control for the communication parameters.

tnx everybody!!!!!

Bar

TTony5
New Contributor I
129 Views

Hi everyone,

I am having a similar problem but pretty weirds things are happenig:

If I interconnect two Edisons UART using the Arduino breakout boards everything works fine. My application receives and sends data from/to the other Edison and I can also use the cat and echo commands to ttyMFD1 successfully.

The VERY WEIRD problem comes when mounting the Edison compute module on a custom-made PCB on which, at the other end of the UART, there is a microcontroller communicating with the Edison. The application on the Edison (using Java mraa library) cannot receive any data from the UART, however, a cat /dev/ttyMFD1 command shows the data perfectly arriving to the UART.

The same code that works when interconnecting two edison does not work when connecting one edison to a microcontroller, however data is seen by the Linux cat on ttyMFD1.

Any hints about this, anyone, please?

Reply