Hi
I'm trying to communicate with the NIRscan nano over the UART expansion connector.
I've written a python script which can open, close, write and write over the COM port to which i attached the NIRscan.
But I'm struggling with defining the bytes I have to send over to get a useful response.
Right now I'm just trying to get any response such that I can confirm that my setup is working.
According tot he documentation i need to send the following:
- Start bytes 65 66 67 68
- Checksum bytes ?? ?? ?? ??
- Flag bytes 11????0
- Sequence ??
- Length ??
- Command ?? ??
- Data 42 (I want to perform a 'Read file list')
- End bytes 68 67 66 65
import serial import time ser = serial.Serial( port='COM6', baudrate=115200, parity=serial.PARITY_NONE, stopbits=serial.STOPBITS_ONE, bytesize=serial.EIGHTBITS, timeout=1 ) ser.flushInput() ser.flushOutput() if ser.is_open == 1: print("Port is open") start_bytes = bytearray([65, 66, 67, 68]) ser.write(start_bytes) checksum_bytes = bytearray([0, 0, 0, 0]) ser.write(checksum_bytes) flag_byte = 112 ser.write(flag_byte) sequency_byte = 0 ser.write(sequency_byte) length_bytes = bytearray([0, 0]) ser.write(length_bytes) command_bytes = bytearray([42, 0]) ser.write(command_bytes) data_bytes = bytearray([0, 0, 0, 0]) ser.write(data_bytes) end_bytes = bytearray([68, 67, 66, 65]) ser.write(end_bytes) print("Data sent") print(ser.read()) ser.close() if ser.is_open == 0: print("Port is closed")