Read USB Serial data and write to SD card #710
Replies: 10 comments
-
Posted at 2014-09-02 by @gfwilliams Well, looks like what you have there should work - but you're using Serial1 which is an actual serial port - not USB. Try removing Serial1.setup, and change the next like to USB.on. You may also need to move the console over to another place so that the data you're sending over USB doesn't get interpreted as JavaScript. You can move it out the way with LoopbackA.setConsole() - but after that you will probably need to reset Espruino with the button before you can reprogram it. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-09-02 by Owen Still nothing I'm afraid. Is it possible to send data to Espruino while watching it in the IDE over bluetooth? To give you some more info on what I'm trying to do, my goal is to use Espruino as the controller for a TV Ambilight system. The software on the PC is AmbiBox (http://www.ambibox.ru/en/index.php/Main_Page) it analyse whatever is on the PC screen into colour blocks and send it over serial port to Espruino which will then control an RGB LED strip. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-09-03 by @gfwilliams Yes, what you want to do should work fine... And yes, you can still control Espruino over Bluetooth - just make sure that you do use Serial1.setConsole beforehand. But actually I just saw something: in your code example you write |
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-09-04 by Owen Hey Gordon,
Running this through ([http://frhed.sourceforge.net] Frhed Hex editor) I get something more readable but I'm still not sure what format it is in:
|
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-09-05 by @gfwilliams Which one of the various devices is AmbiBox set to output as? It's possible that another type would output as something more human readable (or that there'd be documentation on it somewhere)? As far as I can see from the contents of the text file, you've got blocks of 15 bytes... I don't know where they start or end, but they seem like they could be something like:
That's only 4 LEDs worth of data though... do you think that's right? So to read it you could probably do something like you've got already, but with:
and then once you've extracted the 12 bytes string, you could shove it right into |
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-09-06 by Owen I've tried all the of the different AmbiBox outputs, most of them sent data down the COM port but Espruino still only receives the same unreadable text. I again tried the example here http://www.espruino.com/USART using this new line breaker but it is still unreadable: I'm not sure why to try next? |
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-09-08 by @gfwilliams The output wouldn't be readable as it's just a string of binary data - ideally you'd shove it straight into some LEDs so you could see it... You should be able to output the actual values doing something like this though:
|
Beta Was this translation helpful? Give feedback.
-
Posted at 2015-03-22 by user53899 I am new to Espruino and have just had a lot of difficulty with this. For that reason I am posting my solution for future reference. Sorry to raise the dead. The following code allows me to toggle LED1 via
|
Beta Was this translation helpful? Give feedback.
-
Posted at 2015-03-23 by @gfwilliams Hi - thanks for posting up... The TTY would almost certainly be different, but a command like I'm not sure about the code that you post though - is that for an Espruino board? When Espruino is connected by USB, data comes in on the
is more likely to work. Maybe you had the code in there already, and it only started working when you moved the console away from USB with: |
Beta Was this translation helpful? Give feedback.
-
Posted at 2015-03-23 by @gfwilliams Just to add, it depends what you want to do, but often for this kind of thing it's easier to work with the console interface rather than against it. You can just send the JS command directly from your Mac:
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Posted at 2014-09-01 by Owen
Hello,
How do I go about reading Serial data coming from a PC via USB and write that to the SD card?
I've tried the code below but nothing gets written to data.txt and LED2 doesn't flash.
Beta Was this translation helpful? Give feedback.
All reactions