Project

General

Profile

Write UART2 RS-485 API

Added by Joe Hung about 12 years ago

Hi,

I want to use RS-485 to control other device.
Now I can control uart2 from mitydsp-l138 (not FPGA module), but I don't know how to control RS-485 TXE signal on linux.
The TXE de-assert is too late if I control it by linux gpio export (attached the gpio.cpp)

I search the 8250.c in the linux kernel driver and found can set RS-485 mode in it.
But I don't know how the use it on my program using eclipse after kernel already build and run.
Does it have any example?

Thanks,
Joe


Replies (3)

RE: Write UART2 RS-485 API - Added by Joe Hung about 12 years ago

Sorry I forgot the file.

gpio.cpp (2.03 KB) gpio.cpp

RE: Write UART2 RS-485 API - Added by Michael Williamson about 12 years ago

Hi Joe,

I am attaching some sample code (a transmit program, and a receive program) that we used to test the RS-485 patches made at Critical Link for another customer.

This code will work with the 2.6.34-rc1 kernel code (the "master branch") included with MDKs up through Release 2011.12. The latest kernel (from the mitydsp-linux-v3.2 branch) does not have the patches for controlling the data enable via GPIO pin ported in yet. If you are using the latest MDK / 3.2 kernel branch, let me know and we'll try to forward port the code. Or you can try to patch it your self (see this patch from the master branch). We had hoped to submit the patches to the mainline but haven't had time yet, and I expect that it may get some resistance.

The code requires you to correctly select the GPIO pin that the 8250.c pin controls and pass it in as part of the TIOCSRS485 ioctl. The GPIOs are likely different on the Industrial I/O board dev kit than this sample application. If I get a chance to correct that and re-test it I'll follow up on this post.

-Mike

recv.c (1.78 KB) recv.c RS485 receive example code.
send.c (1.62 KB) send.c RS485 send example code.
Makefile (137 Bytes) Makefile simple makefile
rs485_example.tgz (1.29 KB) rs485_example.tgz send.c, recv.c, Makefile in compressed tarball

RE: Write UART2 RS-485 API - Added by Joe Hung almost 12 years ago

Hi Mike:

Thanks for your response. It is working with the 2.6.34-rc1.
It is good timing to assert/de-assert TXE.
I am not sure that we need linux-v3.2 or not. I will try to patch it if we need.

Thanks,
Joe

    (1-3/3)
    Go to top
    Add picture from clipboard (Maximum size: 1 GB)