REXYGEN Community Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Login

    Communication with USBRLY82

    Communication (RS232, RS485, I2C, SPI, UDP, TCP, ...)
    serial rexlang
    2
    2
    373
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • C
      contactform
      last edited by

      Hi,
      I am trying to connect to a USBRLY82 (RobotElectronics) board over serial port (ttyACM0).

      I have no problem sending commands to the board and action relays on it. Where I am facing issues is reading the DI status from the board and that is because to read the state of those DI’s I need to first Write() to the board and the board will send back the status once it receives the command. The value returned by the board is the value that I am trying to get. I can not get it through Read() since the Write() is non-blocking and by the time it get’s executed, the data sent by the USBRLY82 board as an answer, is not there anymore.

      Is there anything that can help me with this? The read and write commands in REXLANG C-like are non-blocking. Can you please let me know if there is anything that I can do about it?

      Best regards,
      George

      cechuratC 1 Reply Last reply Reply Quote 0
      • cechuratC
        cechurat @contactform
        last edited by

        Hi George,

        Thanks for your question. You need to create a kind of state machine which basically does the following (one line = one task period):

        • Write() - send a read request to the device
        • Read() - save received data and length into a global buffer/variable and distinguish if the received message is complete
        • Retry and repeat Read() if the previously received message was not complete

        You will need to introduce a timeout - it can happen that you lost some data so there should be some timeout when you say "Message incomplete, resend the read request".

        Cheers,
        Tomas

        1 Reply Last reply Reply Quote 0
        • First post
          Last post

        This is a community forum for REXYGEN users and fans. Detailed information can be found at REXYGEN homepage.

        There is also an outdated REXYGEN community forum.

        Powered by NodeBB.