Home/Support/Support Forum/Transparent connection and rs485
Welcome to Digi Forum, where you can ask questions and receive answers from other members of the community.

Transparent connection and rs485

0 votes
Hello

i got a problem i need to write program using digi connect me and net+os 7.4. The program needs to be able to allow a transparent connection (TCP/ip -> RS485) and at the same time the digi it self must be able to use the RS485 connection for its own data. Of course this must be multiplexed on the rs485 line. But how to created the transparent connection is still a big black hole for me. Do i need to use the realport driver for something like this or can i store incoming data on a certain port in a buffer so that i can read it out once in a while??

any suggestion would be welcome

yours sincerely,

Tim
asked Jul 14, 2010 in NET+OS by Timmie New to the Community (16 points)
recategorized Dec 5, 2013 by tuxembb

Please log in or register to answer this question.

2 Answers

0 votes
You can use standard socket code to read a socket and then send it out the RS485 port. Probably you'll need to have a thread to listen to the socket, a thread to talk to the RS485 port, your main application, and a semaphore to mark who "owns" the RS485 port. When the main application needs to talk to the RS485 port, it will take the semaphore, which will block the socket thread from passing its data, send its data, then release the semaphore so that the socket thread can continue. The socket thread will do the same whenever it has data to send, take the semaphore, send the data, then release it. Neither should hog the port for too long. Presumably your data will be "bursty", as in, individual commands or sensor readings or the like, which will give you natural points at which to decide to send it versus buffer it. If your app needs continuous data from the outside, you'll need to work out another mechanism to let the Digi app take over when it needs to.

Look in the help, and on the net, for socket functions like listen, accept, and select. Just about any code you find for unix/linux or even Windows, at this level, can be modified to work on NetOS. How you do certain things like blocking mode versus non-blocking might be different, but not much.
answered Jul 14, 2010 by daworm Community Contributor (54 points)
0 votes
thx for the quick and very useful info. I will dig deeper into it, many thx

yours sincerely,

Tim
answered Jul 14, 2010 by Timmie New to the Community (16 points)
...