Advertisement
Prin_Di

RS485

May 28th, 2022
982
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import serial
  2.  
  3. port = serial.Serial('COM5')
  4. port.baudrate = 9600  # Set Baud rate to 9600
  5. port.bytesize = 8  # Number of data bits = 8
  6. port.parity = serial.PARITY_EVEN
  7. port.stopbits = 1  # Number of Stop bits = 1
  8.  
  9. if port.is_open:
  10.     print("Success")
  11.     len_return_data = port.inWaiting()
  12.     print(len_return_data)
  13.     return_data = port.read(len_return_data)
  14.     str_return_data = str(return_data.hex())
  15.     feedback_data = int(str_return_data[-6:-2], 16)
  16.     print(feedback_data)
  17. else:
  18.     print("Fail")
  19.  
Advertisement
RAW Paste Data Copied
Advertisement