This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <hostdev mode='subsystem' type='usb' managed='no'> | |
| <source> | |
| <address bus='2' device='4'/> | |
| </source> | |
| </hostdev> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from arduino_proxy.proxy import ArduinoProxy | |
| proxy = ArduinoProxy('/dev/ttyACM0') | |
| print "Memoria libre:", proxy.getFreeMemory() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class ArduinoProxy(object): | |
| (...) | |
| def getFreeMemory(self): | |
| val = self.send_cmd("_gFM") | |
| return val | |
| getFreeMemory.arduino_function_name = '_gFM' | |
| getFreeMemory.arduino_code = """ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var ram = proxy.globalData()['arduino_type_struct']['ram_size_bytes']; | |
| var free = proxy.getFreeMemory(); | |
| var pc = Math.floor((free/ram)*100); | |
| logMessage("Free ram: " + free + " bytes of " + ram + " bytes (" + pc + "% free)."); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /*********************************************************************** | |
| * First example. Testing how to use LM335 to read temperature, | |
| * using PyArduinoProxy. | |
| ***********************************************************************/ | |
| var value = proxy.analogRead(0); | |
| logMessage("analogRead(): " + value); | |
| var volt = (5.0/1024.0) * value; | |
| logMessage("volt: +" + volt +"V"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| * FIRST EXAMPLE | |
| */ | |
| var i; | |
| for(i=2; i<=5; i++) { | |
| proxy.pinMode(i, OUTPUT); | |
| } | |
| var j; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Test 74HC164 shift register | |
| import time | |
| from arduino_proxy import ArduinoProxy | |
| def blink(): | |
| print "blink()" | |
| proxy.shiftOut(10, 11, ArduinoProxy.LSBFIRST, 0) | |
| time.sleep(0.5) | |
| proxy.shiftOut(10, 11, ArduinoProxy.LSBFIRST, 255) | |
| time.sleep(0.5) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import random | |
| def rnd_byte(): | |
| return chr(random.randint(0, 255)) | |
| class FakeReadOnlyBinaryFile: | |
| """ | |
| File-like object for reading random data. The ammount of data to generate | |
| is specified when the object is created. | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class SomeTest(unittest.TestCase): | |
| . | |
| . | |
| . | |
| def test_queue(self): | |
| . |