Results 1 to 2 of 2

Thread: Activating Relay's using Serial Port.

  1. #1
    Join Date
    Jul 2012
    Posts
    2

    Default Activating Relay's using Serial Port.

    Hi,
    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.
    Thanks.

  2. #2
    Join Date
    Oct 2017
    Posts
    1

    Default

    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:

    Code:
    #!/bin/bash
    MySerialPort="/dev/ttyUSB0"
    MyLatency="2"
    echo "#include <fcntl.h>
    #include <sys/ioctl.h>
    main()
    { int fd; fd = open(\"${MySerialPort}\",O_RDWR | O_NOCTTY );
    int RTS_flag; RTS_flag = TIOCM_RTS;
    ioctl(fd,TIOCMBIS,&RTS_flag);
    sleep (${MyLatency});
    ioctl(fd,TIOCMBIC,&RTS_flag);
    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.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •