Yesterday you opened one topic about your serial communication. I offered you a solution for the NUL character which seemed to be unwanted:
I think the solution should work but we have no response from you and you left us speculating a) Why is the NUL there? b) Do you have correct parameters for the serial communication? c) Do not you need flow control? etc.
Please first test if my code resolves the problem, confirm what is the source of the NUL characters and let us know about the results and possible problems with the code I offered. After that let’s continue here.
Something for the preparation here:
Please do not ask us to do reverse-engineering of the data your software produces. Discussion here should be primarily about Python, not reverse-engineering puzzles.
- It should be an array, so it is a stream of blocks (array items) of the same size, right?
- What is the exact structure of the single block?
floatwhat size, what format, endianness, padding, separators, something else? b'\xcdL\x07=\xfc\x00\x00 '… It is really hard to read binary data in the default representation of Pythonbytes. Please show them in hexadecimal, show the blocks and their components. Use thehex()method:
>>> b'\xcdL\x07=\xfc\x00\x00 '.hex()
'cd4c073dfc000020'
- Please remove all the code not relevant to the problem (backup your file and copy the removed parts back later if needed). It is just adding distracting noise to our communication. Ideally make minimal runnable code demonstrating the problem.
I think all this should be removed (click to show):
import matplotlib.pyplot as plt
plt.ion()
fig=plt.figure()
i=0
x=list()
y=list()
i=0
- Do you really need to close and open the serial communication? Please try to remove it. Also please test the code from my post (above) which should be better suited for the communication.
ser.close()
ser.open()
data = ser.readline()this expects lines (newline terminated). But you said you are sending an array (binary) so we will probably need a better suited method but we will first need to know the format of the data (points 1-3).
- Why? What is wrong? What are the actual results? What are the expected results?