add argument for serial port
This commit is contained in:
parent
39987eb912
commit
785ba50fc5
1 changed files with 8 additions and 6 deletions
|
@ -4,12 +4,13 @@ from pythonosc import udp_client #pip install python-osc
|
|||
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("--ip", default="127.0.0.1", help="The ip of the OSC server")
|
||||
parser.add_argument("--port", type=int, default=7005, help="The port the OSC server is listening on")
|
||||
parser.add_argument("--port", type=int, default=7331, help="The port the OSC server is listening on")
|
||||
parser.add_argument("--serial", default="/dev/ttyUSB0", help="The usb serial converter port")
|
||||
args = parser.parse_args()
|
||||
|
||||
client = udp_client.SimpleUDPClient(args.ip, args.port)
|
||||
|
||||
ser = Serial('COM4', 9600, timeout=1)
|
||||
ser = Serial(args.serial, 9600, timeout=1)
|
||||
|
||||
ser.write(b'M 6\n') # set output data mode
|
||||
ser.write(b'K 1\n') # set cozir into streaming mode
|
||||
|
@ -26,6 +27,7 @@ while True:
|
|||
data=datastring.split(' ')
|
||||
print(data)
|
||||
|
||||
if len(data)==9:
|
||||
client.send_message('cozir/humidity', int(data[2])/10.0)
|
||||
client.send_message('cozir/temperature', (int(data[4])-1000)/10.0)
|
||||
client.send_message('cozir/co2filtered', int(data[6]))
|
||||
|
|
Loading…
Reference in a new issue