Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo


Demo project doesn't work on Delphi XE2

  • wlame

    After installing components to my RAD studio XE2  I've tried to launch demo project from Indy10 folder and got the "PLC read operation failed!" error in ModbusMaster.exe.
    I put a breakpoint  at the start of msrPLCReadHoldingRegisters function (linked to 'onReadHoldingRegisters' event) on ModbusClient and figured out that this function has not been called at all.
    Debugging Master project I found the place where data is sent  to opened connection (connection opens correctly). It is in IdModBusClient.pas on line 300
    my Buffer at that time was  
    (1, 0, 0, 0, 0, 6, 255, 3, 0, 0, 0, 1)

    ModbusSlave doesn't  feel that it was called and IOHandler.InputBuffer.Size on ModbusMaster equals zero all the time. And that method exits by timeout.

    I've tried to make a new project connecting TIdModBusClient to real device but it results in the same situation.

    Does anyone have any advices for me in that case?

    PS: sorry my English. It's not my first language.

  • wlame

    I discovered that some events on ModbusSlave are still called. Those are (in exact order):
    onError() - here ErrorCode parameter equals 0 and functionCode equals 3

    If I'm not mistaken the 0 in ErrorCode means that no error occured. But if the program recognizes functionCode correctly that means the data arrived to ModBusServer. So the probably error is in forming the inner data of that package on ModBusClient component. I'll try to figure that out by  reading sources and according it to modbus specification  but I'm not sure in my skills. Does anyone face this problem?

  • wlame

    Thank's for your link bors-rus. But the problem was solved in another way.
    I haven't got it works correctly on Demo project. But it starts working with real modbus device instantly when I change modbus address (NetID) from 1 to 2. I've noticed there's no matter what UnitID value is set on IdModbusClient component - it works with  device with any UnitID. Most likely I have not enough experience with it  and it's a kind of feature (say like broadband mode) provided by modbus.
    Anyway I've got a connection to my device by this component and it's look like working correctly. Great thanks to plpolak for his work.
    The topic question wasn't solved but the final problem has gone.