Infineon / magnetic-3d-mini-controller

MIT License
6 stars 3 forks source link

Serial Read not working. #1

Closed veysiadn closed 1 year ago

veysiadn commented 2 years ago

Hello, I have XENSIV(TM) 3D Magnetic Sensor 2GO kit, and I was trying to read the sensor data via a python script. I'm using Windows 10, and anaconda environment, with all required libraries are installed with the specified version. Serial connection and serial write functions are working fine, however when I try serial read, it blocks, and no data is received. Here is my code :

ser = getXMCserialConnection() ser.flushInput() string = "5A E8 5A DF 5A CB" #Long range - Fast mode - Start periodic readout cmd_bytes = bytearray.fromhex(string) ser.write(cmd_bytes) time.sleep(0.1) print("Serial writing done") msg_b = ser.read(8) print("Serial reading done") encoded = str(base64.b16encode(msg_b)) print(encoded) encoded = encoded.replace("b'","") encoded = encoded.replace("'","") print("Encoded: ",encoded) B = read_hex(encoded) print('Bfiled : ') print(B)

Although serial reading is blocking

OUTPUT : XMC found on port: COM5 Serial Connection Done Serial writing done

There's no output after that, I think serial read blocks until it reads but since there's no received data, it waits. I have to unplug the device to stop the application. This readout will be in a while loop, the snippet above was just for test purpose.

Deepa-Ven commented 2 years ago

Hi @veysiadn ,

Did you run the m03_TestStateDetection.py file and did you get any output for that? Was it reflecting the positions? Also did you run the calibration file?

Deepa

r0bertka commented 1 year ago

Hi, I have the same issue as @veysiadn, using more or less the same code snipped that they have posted. Opening the connection works, but reading from the device leads to something getting stuck. I have to physically unplug the device to make the script stop. That also happens when I send the read command right away after opening the connection (without the write command) which to my understanding should at least give me back an empty byte string. @veysiadn: were you able to find the reason for the issue?

veysiadn commented 1 year ago

Hello @r0bertka, it's been a while that I posted this issue, but what I remember about the solution is that you have to run the calibration file with the steps mentioned in the README of this repo. For now, I'll leave the issue open, or if you want to open a new issue, please let me know, so I can close this issue.