RS485 character receiving

Hi,

I'm trying to use the RS485 of the NanosG20. Writing to the device works fine. But I can't read even a single character.

I set up the port to 8n1 and 9600 baud. After clearing the RTS I'm able to send a test string (which is correctly received by another hardware). After this point I'm stuck because a receive never returns anything. I've tried to set/clear RTS and DTR.

I've attached a reduced test C code. It worked on other RS485 with linux already, these RS485 driver had switched automatically between sending and receiving on the RS485 line.

I'm sure the mistake is in my head. :) Any hints for me?

Thanks,

- David

AttachmentSize
com.c817 bytes

Re: RS485 character receiving

When using RS485 on NanosG20 setting up the receiver (PB29 = low) is required as described in HOWTO: RS485 on Embedded Linux Boards.

Re: RS485 character receiving

Okay it works. Thank you, I haven't seen this page.

I've tried to use the code of the example "Enable or disable RS485 mode". But the C compiler on the NanosG20 complained about the structure called "serial_rs485" in linux/serial.h because it's not definied (the constants also like TIOCSRS485). Do you have any suggestions?

Thanks,
- David

Re: RS485 character receiving

The Debian distribution (Lenny) installed on NanosG20 offers linux-headers-2.6.26 while the kernel is a 2.6.35. So these headers are quite old and can be replaced by the ones from kernel 2.6.35.

Re: RS485 character receiving

It would be best to not replace the whole linux headers but just take the linux/serial.h from the kernel 2.6.35 and include it in your program.

Re: RS485 character receiving

Thank you, it works wunderful now. Created a stripped header and included it.

Have a nice friday. ;)

Re: RS485 character receiving

Hi,

David, may you upload the final version of your code please.
I've got some problems, recieving data, and it would be nice to see how you managed the communication.

For me it's like in your first post, I'm also sure, the mistake has to be in my head.

I'm sorry, but posting my code isn't possible by now.

Thanks,

Madd

Syndicate content