From: "Carlo E. Prelz" Date: 2012-12-19T18:34:33+09:00 Subject: Re: Comunication via rs485 Subject: Comunication via rs485 Date: Wed 19 Dec 12 05:39:15PM +0900 Quoting iosu bueno (lists@ruby-forum.com): > Is there any way to comunicate via rs485 with ruby? Any gem or project > already made by someone? I need to do that in m project and id like to > do it with Ruby instead of using a conversor to read rs232. Back in 2009 I needed to talk to a device via rs485. Eventually, due to the distance to the device, I had to use a gizmo that converted the conversation to ethernet-based. But while I tested the code I had the device on my desk, and thus talked native rs485. Well, once my serial port was properly configured to talk rs485 (in my case I needed to change the position of a few hardware jumpers on the PCI board) I talked to the port as I would to any other serial port. before opening the port I called stty as follows system("stty -F /dev/#{@dev} speed #{@speed} -brkint -icrnl -imaxbel -opost \ -onlcr -isig -icanon -iexten -echo -echoe -echok -echoctl \ -echoke ignbrk -ixon -ixoff hupcl" (where @dev was the appropriate ttySxx, and the speed was the expected comms speed). Then I opened the unit as follows: @unit=File::open('/dev/'+@dev,File::RDWR) and I would use @unit.syswrite and @unit.sysread as normal. It was the first and last time I had to do with rs485. I was VERY happy that everything worked, that's for sure. Now I do not even have that PCI card anymore, so I cannot give you much more advice. HTH Carlo -- * Se la Strada e la sua Virtu' non fossero state messe da parte, * K * Carlo E. Prelz - fluido@fluido.as che bisogno ci sarebbe * di parlare tanto di amore e di rettitudine? (Chuang-Tzu)