Initial test
This commit is contained in:
36
serialConnect.py
Normal file
36
serialConnect.py
Normal file
@@ -0,0 +1,36 @@
|
||||
import serial
|
||||
|
||||
ser = serial.Serial('/dev/ttyACM0', 115200, timeout=1)
|
||||
if ser:
|
||||
print("Terhubung!")
|
||||
else:
|
||||
print("Gagal terhubung.")
|
||||
|
||||
#ser.write(b'\r\n')
|
||||
#response = ser.read(100)
|
||||
#print("Response:", response.decode(errors='ignore'))
|
||||
|
||||
#ser.write(bytes.fromhex('02 00 00 00 00 00 00 03'))
|
||||
#response = ser.read(100)
|
||||
#print("Response:", response.hex())
|
||||
|
||||
#while True:
|
||||
# data = ser.readline()
|
||||
# if data:
|
||||
# print("Received:", data.decode(errors='ignore'))
|
||||
|
||||
|
||||
#ser.write(b'~RS\n') # Try Reset
|
||||
ser.write(b'~VER\n') # Try Version
|
||||
ser.write(b'~ID\n') # Try Device ID
|
||||
response = ser.read(100)
|
||||
print("Response:", response.decode(errors='ignore'))
|
||||
|
||||
#ser.write(b'INFO\n')
|
||||
#ser.write(b'PING\n')
|
||||
##response = ser.read(100)
|
||||
#print(response.decode('utf-8'))
|
||||
#ser.write(b'RESET\n') # Kirim perintah reset
|
||||
#response = ser.read(100) # Baca respons dari mesin
|
||||
#print(response.decode('utf-8'))
|
||||
ser.close()
|
||||
Reference in New Issue
Block a user