View Full Version : Activating Relay's using Serial Port.

July 30th, 2012, 10:36 AM
I have a relay card(AR-2S) from eeci that allows the control of two relay's using the Serial Port:

<< AR-2S are controlled with RTS and DTR which are RS-232 control lines that are primarily used for
controlling a modem (RTS=request to send and DTR=data terminal ready). The number 1 relay is energized by
placing RTS high by setting bit 1 in the modem control register. The number 2 relay is energized by placing DTR high
by setting bit 0 in the modem control register.>>

Can anyone give me the general directions to achieve control of the Relay's using Gilder 5 Pro. My knowledge of Lua Script is very limited.
Any help would be welcome.

October 21st, 2017, 10:02 AM
I have published a detailed answer here: forums dot gentoo dot org slash viewtopic-p-8132756 dot html
(i subscribed only to answer this post; and recent members are not allowed to post links)

Here is the short version:

echo "#include <fcntl.h>
#include <sys/ioctl.h>
{ int fd; fd = open(\"${MySerialPort}\",O_RDWR | O_NOCTTY );
int RTS_flag; RTS_flag = TIOCM_RTS;
sleep (${MyLatency});
close(fd); } " | tcc -run -

Note that sending data on TX will probably mess RTS; see the Gentoo forum for details.

I am not sure it's possible to activate DTR and RTS pins independently from shell, it's probably possible from C background daemon; but unsure via pure shell.

This answer comes a bit late, but after several days of Googling, all similar questions are left without answer. Now, this topic has an answer for people who will have a similar issue in the future.