Menu

Read FIFO Queue issue

malled
2013-10-08
2014-03-19
  • malled

    malled - 2013-10-08

    Hi,

    I have an problem with your Read FIFO Queue implementation.
    The Modbus frame response format should be

    ...
    Function code (1Byte)
    Byte count (2Byte)
    FIFO count (2Byte)
    FIFO data (2 * FIFO count)

    and your code for reading this response:

    ReadFIFOQueueResponse.java Line 148

    public void readData(DataInput din) throws IOException {
        m_Count = din.readShort();
        m_Registers = new InputRegister[m_Count];
        for (int i = 0;i < m_Count;i++)
            m_Registers[i] = new SimpleInputRegister(din.readShort());
    } 
    

    so m_Count is now the Byte count but it should be the FIFO count.

    My Fix for that looks like this

    public void readData(DataInput din) throws IOException {
        din.readShort();             // remove byte count
        m_Count = din.readShort();
        m_Registers = new InputRegister[m_Count];
        for (int i = 0;i < m_Count;i++)
            m_Registers[i] = new SimpleInputRegister(din.readShort());
    } 
    

    Am I right or had I misunderstood the read FIFO queue message?

    btw. thanks for the great modbus stack.

     
  • Julie Haugh

    Julie Haugh - 2014-03-19

    You're correct - there are two counts, which are a bit redundant. The first register is the byte count (call it "N"). The second register is the queue count (call it "M"). It turns out that "M" should always be ((N - 2) / 2).

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.