CN0359 Crashing when send "poll" command

Hello,

I have a program to automatically log from some CN0359 boards. This works, and I am able to log data from my CN0359 boards.

My issue is that the CN0359 boards will randomly crash when I poll from them.

By crash, I mean the board becomes entirely unresponsive. The screen freezes on whatever was most recently on it, and the input nob/button does not do anything. A power cycle is required for me to fix the boards.

This usually happens within 1-2hr of when I started logging, and I have had it happen as quickly as 1min.

It seems like the boards crash faster if they are being polled more frequently. I have tested polling rates between 0.25s and 2s.

I have tested a couple of baud rates, but it does not seem to have an effect on the boards crashing. I am currently using 38400 bits/s.

I have observed this behavior on all of the 3 boards I have tested.

The boards do not crash like this unless I am polling them. I have left them reading overnight multiple times with no issues.

Has anyone experienced anything like this?

Thanks in advanced.

- osullivan

Parents
  • 0
    •  Analog Employees 
    on May 25, 2021 1:30 PM

    Hi osullivan,

    Sounds like you have probably found a bug in the code. What are you doing to continuously poll the board? Are you controlling it from a Python script or similar? The likely culprit is probably somewhere in the UART function/libraries or in the ADC interrupt function, given that it happens only when trying to actively poll the converter and send the data over. We'll start to have a look at this, but it might take us a bit of time to track down this issue, would you be able to share any scripts or files you are using to poll the device? This would help us find the problem sooner if we can work on a common setup. Also if there is anything else you changed that would be helpful to know up front.

    Cheers,

    Brandon

  • I wrote a small python script that I can reliably get to crash the CN0359 boards, I included it at the bottom of this post.

    For my setup, I have two CN0359 boards connected in series (standard RS485 wiring) to a single USB to RS485 converter.

    I have each of the boards set to 57600 baud, and they have the addresses 1 and 2. The USB to RS485 port is on COM11 for my computer. (I found the configuration of these settings do not impact the issue)

    While I was testing this script, I noticed something odd. when I set `CN0359_ADDRESSES = [1,]` (so I am just polling board 1) board 2 is the one that crashes, despite it never being polled.

    I thought the issue must be to do with how the boards reject messages not meant for them (ex sending `poll 3\n` to a board with address 1), but I was unable to crash boards 1 or 2 by just sending them `poll 3\n` over and over (I only ran this test for a couple of minutes though).

    It appears that this issue only appears when there are multiple CN0359 boards on the same RS485 network and it has to do with one board crashing while listening to the output of another board

    Additionally, I have tested values of `WAIT_BETWEEN_POLLS` up to 2s and still observed these crashes.

    I have not tried adding delay between the characters, like andrie1994 suggested, but I do not believe that would fix the issue because I was not able to crash either of my boards be repeatedly sending `poll 3\n`.

    Let me know if you need any clarification or more information about my setup.

    from typing import List
    from serial import Serial
    from time import sleep
    
    ##############################################################
    # CONFIGURATION
    
    COM_PORT = 'COM11'
    BAUD_RATE = 57600
    SERIAL_TIMEOUT = 0.5
    CN0359_ADDRESSES = [1, 2]
    
    WAIT_BETWEEN_POLLS = 0
    ##############################################################
    
    
    def poll(ser: Serial, addresses: List[int]) -> str:
        lines = []
        for address in addresses:
            lines.append(f'---------- ADDRESS {address} ----------\n\n')
    
            ser.write(f'{address} poll\n'.encode())
    
            for _ in range(22):  # CN0359 returns 22 lines on `poll`
                line = ser.readline().decode("utf-8")
                if line == '':
                    raise ConnectionError(address)
                lines.append(line)
    
        return ''.join(lines)
    
    
    if __name__ == '__main__':
        ser = Serial(COM_PORT, BAUD_RATE, timeout=SERIAL_TIMEOUT)
    
        try:
            while True:
                print(poll(ser, CN0359_ADDRESSES))
                sleep(WAIT_BETWEEN_POLLS)
        except ConnectionError as e:
            print()
            print(f'NO RESPONSE FROM ADDRESS {e.args[0]}')
            input('press [enter] to quit.\n')
    

Reply
  • I wrote a small python script that I can reliably get to crash the CN0359 boards, I included it at the bottom of this post.

    For my setup, I have two CN0359 boards connected in series (standard RS485 wiring) to a single USB to RS485 converter.

    I have each of the boards set to 57600 baud, and they have the addresses 1 and 2. The USB to RS485 port is on COM11 for my computer. (I found the configuration of these settings do not impact the issue)

    While I was testing this script, I noticed something odd. when I set `CN0359_ADDRESSES = [1,]` (so I am just polling board 1) board 2 is the one that crashes, despite it never being polled.

    I thought the issue must be to do with how the boards reject messages not meant for them (ex sending `poll 3\n` to a board with address 1), but I was unable to crash boards 1 or 2 by just sending them `poll 3\n` over and over (I only ran this test for a couple of minutes though).

    It appears that this issue only appears when there are multiple CN0359 boards on the same RS485 network and it has to do with one board crashing while listening to the output of another board

    Additionally, I have tested values of `WAIT_BETWEEN_POLLS` up to 2s and still observed these crashes.

    I have not tried adding delay between the characters, like andrie1994 suggested, but I do not believe that would fix the issue because I was not able to crash either of my boards be repeatedly sending `poll 3\n`.

    Let me know if you need any clarification or more information about my setup.

    from typing import List
    from serial import Serial
    from time import sleep
    
    ##############################################################
    # CONFIGURATION
    
    COM_PORT = 'COM11'
    BAUD_RATE = 57600
    SERIAL_TIMEOUT = 0.5
    CN0359_ADDRESSES = [1, 2]
    
    WAIT_BETWEEN_POLLS = 0
    ##############################################################
    
    
    def poll(ser: Serial, addresses: List[int]) -> str:
        lines = []
        for address in addresses:
            lines.append(f'---------- ADDRESS {address} ----------\n\n')
    
            ser.write(f'{address} poll\n'.encode())
    
            for _ in range(22):  # CN0359 returns 22 lines on `poll`
                line = ser.readline().decode("utf-8")
                if line == '':
                    raise ConnectionError(address)
                lines.append(line)
    
        return ''.join(lines)
    
    
    if __name__ == '__main__':
        ser = Serial(COM_PORT, BAUD_RATE, timeout=SERIAL_TIMEOUT)
    
        try:
            while True:
                print(poll(ser, CN0359_ADDRESSES))
                sleep(WAIT_BETWEEN_POLLS)
        except ConnectionError as e:
            print()
            print(f'NO RESPONSE FROM ADDRESS {e.args[0]}')
            input('press [enter] to quit.\n')
    

Children
No Data