Detecting com errors when using SysComRead

MortenL
2019-02-25
2019-03-04
  • MortenL - 2019-02-25

    Hello

    I'm using a Wago 750-8214 to communicate with a printer using RS232 and the SysCom library.
    I request a status message from the printer to monitor paper status etc.
    This is done using SysComRead.

    My question is, how do I detect if for example a wire break occurs and no new messages are received?
    I've been looking for a message counter or something similar, but I've been unable to locate it.
    I think it could also work if it was possible to reset the buffer that the syscomread reads from, but currently it constantly returns the last value received if the wire breaks.

    I've used other PLCs that used their own function block for RS232 communication and this had the error detection functionalty already built-in, so I assume it is possible, I've just been unable to locate it.

     
  • MortenL - 2019-02-26

    I have sorta solved it, but there's probably a better way

    I tried using SysComPurge to make SysComRead return 0 to the buffer, that's obviously not how it works.
    Now I'm using SysMemSet to 0 all values in the a_bPrinterStatus before asking SysComRead to fill it again.
    This gets me the result I want, in case of a wirebreak or faulty printer it will not retain the last received value, but 0 all values instead.

    I do however feel that this is not the correct way of doing it.

    IMG: Bild

     
  • dFx

    dFx - 2019-02-27

    Wire break issues aren't port related statistics ?

     
  • MortenL - 2019-02-28

    dFx hat geschrieben:
    Wire break issues aren't port related statistics ?

    If no new messages are received in a timeperiod where I was expecting messages, this would indicate that the device that was supposed to transmit it is not responding, would it not?
    This could in turn indicate a defective device or a wire break.
    Therefore a message received counter, or something similar, could help determine problems.
    I use other devices that use their own communcation libraries, and often similar functionality is built-in.

    How would you detect a problem with the current syscom library?

     
  • dFx

    dFx - 2019-02-28

    What is your timeout setting ? This is more or less what you are trying to achieve. Check you pResult^ value (statusResult).

     
  • MortenL - 2019-03-01

    dFx hat geschrieben:
    What is your timeout setting ? This is more or less what you are trying to achieve. Check you pResult^ value (statusResult).

    I have tried various timeout settings (0-10-20-100) And StatusResult always stays at 0.
    I can disconnect the device and the result will still be 0.
    My original plan was using the result as you suggest, but the constant value of 0 threw me off, and I assumed that it wasn't possible to use it that way.

     
  • dFx

    dFx - 2019-03-01

    Have you tried using SysComSetTimeout function ?

    maybe you can succeed runing CAA_SerialCom library (which uses syscom internaly).

     
  • MortenL - 2019-03-01

    SysComSetTimeout didn't make any difference

    I made a quick 'n dirty test:

    I still get 'NO ERROR', but szSize correctly changes whether or not it is actually receiving new data, I can use this for error detection.

    Judging by the list of errors available:

    NO_ERROR
    0 no error

    FIRST_ERROR
    5000 first library specific error

    TIME_OUT
    5001 = timeout error

    ABORT
    5002 = abort input active

    HANDLE_INVALID
    5003 = handle invalid

    ERROR_UNKNOWN
    5004 = unknown error

    WRONG_PARAMETER
    5005 = wrong parameter

    WRITE_INCOMPLETE
    5006 = write incomplete

    FIRST_MF
    5050 first manufacture specific error

    LAST_ERROR
    5099 last library specific error

    It is not supposed to give me any errors in an event like that.

    Working with it I'm slowly beginning to understand why it does the things the way it do it.

    pBuffer is only updated if new data is available, I wrongfully assumed that if no data was available it would be the same as sending data with the value of 0.
    I now realize that updating it to 0 value when no data is available would be a bit senseless and illogical.

    The 'NO ERROR' also makes makes sense, I would like an additional 'no data received within timeout limit' or something like that, but this will be relatively easy to do myself now that I have szSize.

    IMG: Bild

     
  • e.kislov - 2019-03-01

    Zitat:
    SysComSetTimeout didn't make any difference

    Because it's not working:
    l viewtopic.php?t=9293#p22836 l

     
  • MortenL - 2019-03-04

    e.kislov hat geschrieben:
    Because it's not working:
    l viewtopic.php?t=9293#p22836 l

    I see, well there's no point in trying to get it to work then, thanks for the heads up.

     

Log in to post a comment.