Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Roline RS232 to Ethernet and Socat
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware
View previous topic :: View next topic  
Author Message
MacGyver031
Tux's lil' helper
Tux's lil' helper


Joined: 11 Jul 2004
Posts: 141
Location: Ilavalai, Sri Lanka

PostPosted: Wed Nov 17, 2010 3:36 pm    Post subject: Roline RS232 to Ethernet and Socat Reply with quote

Hi folks,
I am in the process of creating modules for my automated home project. In the home-office I have a 24/7 server which has one 8port relay card connected to /dev/ttyS1. This is quite cool and I have implemented a web frontend so I can use my homepage and mobile device to switch on and off my printers, computer and other things in the home office.

Now I have bough a second 8port relay card and a Roline RS232 to Ethernet gateway (15060015). This combination will be implemented in my living room taking care of switching on/off the lights, water pump etc. BUT I have run into a problem:

Code:
socat pty,link=$HOME/vmodem0,raw,waitslave IP_OF_ROLINE:PORT

successfully connects to the relay card, BUT over 30% of the commands (commands are 4byte raw data with all combination) arrive corrupted! That means that the relay card is not switching reliably.

I have connected to a second PC to the Roline with a null-modem cable and have seen that socat -> roline link is unable to zmodem transfer data! while roline -> socat works without error!

I have the feeling that socat is not going into full (blind-)raw mode, it interprets some byte(s).

Could any one help me on this? I have used the winows-driver and the windows control-software for the relay card which seems to work. The software which works directly with the /dev/ttyS0 works fine too, so I conclude that socat must be "superfine" tuned so I can go on with my project.

Thanks.
_________________
Sincerely your
Joanand K.

MacBook Pro 5.1: 2.4GHz Core2 Duo, 4096MB, 500GB, NVidia 9400/9600 M GT
Gentoo, Kernel 3.4.9, XOrg, Fluxbox.
Back to top
View user's profile Send private message
BradN
Advocate
Advocate


Joined: 19 Apr 2002
Posts: 2391
Location: Wisconsin (USA)

PostPosted: Fri Nov 19, 2010 5:14 am    Post subject: Reply with quote

I'm not sure if this will help you or not, but look into the stty command, it has options to configure tons of stuff like that.

That said, 30% seems high, are you sure you don't actually have the port in 7 bit or parity mode or something?

Maybe knowing the pattern of corruption would help.
Back to top
View user's profile Send private message
TJNII
l33t
l33t


Joined: 09 Nov 2003
Posts: 648
Location: for(;;);

PostPosted: Sat Nov 20, 2010 6:54 pm    Post subject: Re: Roline RS232 to Ethernet and Socat Reply with quote

MacGyver031 wrote:
socat -> roline link is unable to zmodem transfer data!


Yea, this doesn't surprise me. x/y/zmodem transfers are really fragile. One of my coworkers and I disagree on the exact mechanics, with my position being that the RS232-ethernet conversion does not reliably transfer unprintable characters. My coworkers position is that the transfer is intolerant to timing issues so the data must be on the line when the client expects it, so the bridge must buffer and implement the transfer protocol locally. Regardless, you're probably not going to get zmodem working over a ethernet->rs232 bridge, it is a steep uphill battle. The only thing I can recommend is make sure you have a low number of switches between the converter and the client (preferably a crossover cable for testing) and be sure to use CRC on your transfer.

You can also run RS232 over cat-5 so that you can connect your board to a machine instead of a converter. If you really know your way around a workbench you may want to just make your own relay board that talks straight ethernet or character based RS232.

That said, why does a simple serial relay board use zmodem?
Back to top
View user's profile Send private message
MacGyver031
Tux's lil' helper
Tux's lil' helper


Joined: 11 Jul 2004
Posts: 141
Location: Ilavalai, Sri Lanka

PostPosted: Sat Nov 20, 2010 7:03 pm    Post subject: Reply with quote

Hi,
Thanks,
Port has been set correctly to 8bit, 1bit stop, parity off and controll off (as it sould be).
Pattern which doesn't work are:
0x06
0x30
0xff
and so on, I haven't yet tested others.

Code:
opost=0
seems not to work properly.

I will tryout stty command as soon as possible.
_________________
Sincerely your
Joanand K.

MacBook Pro 5.1: 2.4GHz Core2 Duo, 4096MB, 500GB, NVidia 9400/9600 M GT
Gentoo, Kernel 3.4.9, XOrg, Fluxbox.
Back to top
View user's profile Send private message
BradN
Advocate
Advocate


Joined: 19 Apr 2002
Posts: 2391
Location: Wisconsin (USA)

PostPosted: Sun Nov 21, 2010 9:29 pm    Post subject: Reply with quote

0x30 is ascii numeral "0", so it shouldn't be an issue of nonprintable characters.

I noticed all those values should have the same parity though, does toggling one bit in any of the failing values make it work again?
Back to top
View user's profile Send private message
TJNII
l33t
l33t


Joined: 09 Nov 2003
Posts: 648
Location: for(;;);

PostPosted: Sun Nov 21, 2010 10:17 pm    Post subject: Reply with quote

Connect the RS232 converter to a machine via a null-modem cable and see what the converter is putting out. That will narrow down potential problems.
Back to top
View user's profile Send private message
MacGyver031
Tux's lil' helper
Tux's lil' helper


Joined: 11 Jul 2004
Posts: 141
Location: Ilavalai, Sri Lanka

PostPosted: Sun Nov 21, 2010 10:39 pm    Post subject: Re: Roline RS232 to Ethernet and Socat Reply with quote

TJNII wrote:
That said, why does a simple serial relay board use zmodem?

Hi,
sorry for not being clear: my relayboard needs command of 4bytes (command, relayboard adress, command, xor-checksum), I have seen that the program which I use for a directly connected to the server serial port, works like a charm.
The second board is a bit far away from the server, so I bought a Roline RS232 to Ethernet adapter. When I route the commands created from the program to a socat generated virtual-com-port then the board goes gang ho on some combination of switch-state.
So I wanted to see if the communication is working well and connected the RS232-Gateway to a second computer and ran on both minicom and made some checking. There I saw that socat -> second computer x/y/z modem file transfer do not work! BUT second computer -> socat works!

So I conclude that socat has some payload interpretation (such as stuffing of 0xff to something else), which I would like to switch off. I have not yet had the chance to check the windows-driver of roline well, but I will do it if I am unable to socat work reliably.

Meanwhile I have seen that option
Code:
opost=1
(output processing) is making about 50% less error than
Quote:
opost=0
. I have tested 0x00 - 0x5f and found out that 0x0f is one of the problematic byte. I am on the process of testing all byte-code and will report a.s.a.p.
_________________
Sincerely your
Joanand K.

MacBook Pro 5.1: 2.4GHz Core2 Duo, 4096MB, 500GB, NVidia 9400/9600 M GT
Gentoo, Kernel 3.4.9, XOrg, Fluxbox.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum