Skip to content

Instantly share code, notes, and snippets.

@benpicco
Created February 23, 2014 19:19
Show Gist options
  • Save benpicco/9175887 to your computer and use it in GitHub Desktop.
Save benpicco/9175887 to your computer and use it in GitHub Desktop.
#!/usr/bin/python
# -*- coding: utf-8 -*-
import cmd, serial, sys, socket, threading, readline, time, os
if __name__ == "__main__":
ser = serial.Serial(port="/dev/ttyUSB0", baudrate=115200, dsrdtr=0, rtscts=0)
ser.setDTR(0)
ser.setRTS(0)
time.sleep(1)
id = socket.gethostbyname(socket.gethostname()).split(".")[3]
name = socket.gethostname()
ser.write("set_id " + id + " " + name + "\n")
print("Id set to " + id + ", name set to " + name)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment