I am trying to write a basic GUI in python to communicate with PromSim2 using the commands as listed in the [datasheet](from PDF page 40 onwards).
I am trying to use Python serial mode using the below functions.
def connect_dev():
try:
global access
access=1
ser.flushOutput()
time.sleep(2)
ser.write(b'REMOTE\r\n')
time.sleep(2)
ser.flushOutput()
time.sleep(2)
ser.flushOutput()
ser.write(b'QMODE\r\n')
if ser.read(8)==b'':
raise UnboundLocalError()
else:
status_label.config(text=f"Device in Remote access")
except UnboundLocalError:
status_label.config(text=f"Error! Connect to the COM port")
def BPM_set():
selected_item_list1 = listbox1.get(listbox1.curselection())
selected_item_list1_strip=selected_item_list1[:-3].rstrip()
cmd='NSR'+selected_item_list1_strip
# print(cmd)
ser.flushOutput()
#time.sleep(2)
ser.write(b'{cmd}\r\n')
ser.flushOutput()
time.sleep(2)
print(ser.readline().decode("utf-8"))
if selected_item_list1:
# Perform specific function based on selected item from List 1
print("Selected Item from List 1:", cmd)
Delay addition(sleep) to the function doesn't seem to help so have added couple of flush functions still not sure if anything else I am missing in the BPM_set() functions?
Now, If I want to set 30bpm(table-11) using TeraTerm tool with serial interface properties (port,baudrate=9600,bytesize=8, parity='N', stopbits=1, timeout=2,xonxoff=0) as defined in the datasheet I am able to configure the device. Using TeraTerm after estabilishing the COM connection, I enter REMOTE command and get RMAIN on screen then I enter NSR30 and get OK on the screen indicating the remote access and 30bpm setting successfully done.
Using the Python code 1.The connect_dev function works successfully --> device enters Remote access mode. 2.The BPM_set function which takes the 'NSR' and subsequent numerical value from a list and sends the cmd(the cmd value varies as NSR30) throws '?' or ERR01, UNKNOWN COMMAND.