nano /root/console.py
#!/usr/bin/python import socket import time TCP_IP = '127.0.0.1' TCP_PORT = 6571 BUFFER_SIZE = 1024 s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect((TCP_IP, TCP_PORT)) data = s.recv(BUFFER_SIZE) s.close() print "received data:", data filename=time.strftime("%Y%m%d-%H:%M")+'.log' print filename file_ = open(filename, 'w') file_.write(data) file_.close()
chmod 755 /root/console.py
ATmega32u4 code:
#include <Console.h> void setup() { Bridge.begin(); // Initialize Bridge Console.begin(); // Initialize Console } void loop() { while (!Console); // Wait for the Console port to connect int temperature = random(0, 100); Console.println(temperature); delay(5000); }
Testing:
/root/console.py
Revision ATmega32u4 code:
#include <Console.h> void setup() { Bridge.begin(); // Initialize Bridge Console.begin(); // Initialize Console } void loop() { //while (!Console); // Wait for the Console port to connect if (Console) { int temperature = random(0, 100); Console.println(temperature); } delay(5000); }
Thanks ShapeShifter.
http://forum.arduino.cc/index.php?topic=343641.msg2369342#msg2369342
Comments powered by CComment