Advertisement
Guest User

sane.py

a guest
Mar 21st, 2012
227
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.50 KB | None | 0 0
  1. #!/bin/env python
  2. import serial
  3. from socket import socket, AF_INET, SOCK_STREAM
  4.  
  5. if __name__ == "__main__":
  6.   sock = socket(AF_INET, SOCK_STREAM)
  7.   sock.connect(('localhost',9090))
  8.  
  9.   sock.send('raw\r\n\r\n');
  10.  
  11.   port = serial.Serial('/dev/ttyACM0', 9600, timeout=1)
  12.   line = port.readline() #skip the junk
  13.   while True:
  14.     line = port.readline()
  15.     if line:
  16.       usecs = int(line)
  17.       sock.send('\x00{"receiver":"\/echoTime","msg":{"data":%d},"type":"std_msgs\/Int64"}\xff/' % (usecs,))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement