-
I mean "serialport" as in the npm module :) https://github.com/voodootikigod/node-serialport
I guess my real question was if https://www.npmjs.com/package/espruino would automatically find my espruino if I just plugged it in, or if I had to first figure out what port it was connected to (for example by scanning all ports with node-serialport, looking for something that looks like an espruino)
-
-
-
Ohh, too bad I didn't know about this earlier.
I ended up using the 'serialport' module directly instead...https://github.com/Tobbe/robotgame/blob/master/nodejs/app.js
-
-
-
Hi
When connected to my computer everything works fine. I see the green LED flash twice. But when connected to a USB power supply the ESP8266
connect
callback gets called with an error object, and the red LED is turned on. Any idea why?E.on('init', function() { SPI2.setup({baud: 3200000, mosi: B15}); Serial1.setup(115200, { rx: B7, tx : B6 }); var wifi = require("ESP8266WiFi_0v25").connect(Serial1, function(err) { if (err) { digitalWrite(LED1, 1); throw err; } setTimeout(function () { digitalWrite(LED2,0); setTimeout(function() { digitalWrite(LED2,1); }, 500); setTimeout(function() { digitalWrite(LED2,0); }, 1000); setTimeout(function() { digitalWrite(LED2,1); }, 1500); setTimeout(function() { digitalWrite(LED2,0); }, 2000); setTimeout(function() { wifiResetConnect(wifi); }, 4000); }, 1500); }); });
How do I debug this further?
-
-
I've got my Pico both reading and writing twitter messages! :)
As we know the Pico can't handle HTTPS, which Twitter requires for accessing its API. So I wrote a node.js server that the Pico can talk regular HTTP with, and it'll then relay the messages to Twitter. To send tweets a password is required, so that the server isn't abused.
https://github.com/Tobbe/twitter-api-gw
I run the server on a free OpenShift instance, so no extra hardware is needed for that on my side :)
-
-
I'm doing two get-requests. As soon as I've gotten an answer from the first one I want to do the second one. So something like this
http.get(url, function (res) { res.on('data', function (chunk) { ... }); res.on('close', function () { http.get(url2, function (res) { res.on('data', function (chunk) { ... }); res.on('close', function () { console.log('both get-requests completed'); }); }); }); });
However, it doesn't work :( I get this:
ERROR: Socket error -1 while sending Uncaught Error: CIPSTART failed at line 1 col 177 ...d 0,Error("CIPSTART failed");} ^ in function "b" called from line 1 col 26 {d=void 0;var f;b&&(f=b(a))?(d=p,b=f):clearTimeout(e);void 0... ^ in function "d" called from line 1 col 325 ...c&&(e[c](k),n=!0);n||d&&d(k)}a=a.substr(f+1);"\n"==a[0]&&(a=... ^ in function called from system
I can work around it by wrapping the inner get-call in a
setTimeout
, but that doesn't feel right. What's the correct way to do this? -
-
Yes, please do update the docs :) The whole options object could use some documentation improvements :)
Just noticed that for http.request it says
options An object containing host,port,path,method,headers fields
And for url.parse it says
An object containing options for http.request or http.get. Contains method, host, path, pathname, search, port and query
So url.parse returns a bunch of options (pathname, search, query) not mentioned as supported in http.request (or http.get)
Could you please try to clarify that?
-
I had problems doing a POST, so I started playing around with http.request and noticed that it behaves differently from http.get. Why is that?
This is the code I have
var http = require('http'); function callback(response) { var str = ''; response.on('data', function (chunk) { str += chunk; }); response.on('close', function () { console.log(str); }); } function getDataUsingGet() { http.get('http://example.com', callback); } function getDataUsingRequest() { var options = { host: 'example.com', method: 'get' }; http.request(options, callback).end(); }
Calling getDataUsingGet() I get the same reply as I do when I visit using my web browser. But calling getDataUsingRequest() I get
<?xml version="1.0" encoding="iso-8859-1"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>501 - Not Implemented</title> </head> <body> <h1>501 - Not Implemented</h1> </body> </html>
And changing
method: 'get'
tomethod: 'GET'
the reply I receive is<?xml version="1.0" encoding="iso-8859-1"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>400 - Bad Request</title> </head> <body> <h1>400 - Bad Request</h1> </body> </html>
How can I use http.request to get the same page as http.get() gets me? Why do I get different responses when using 'get' and 'GET'?
-
-
I'd like to encrypt a string with a secret key, that I can later use to also decrypt the string.
What options do we have for that on the Pico? Would this work? http://bitwiseshiftleft.github.io/sjcl/
-
-
In the script I posted above I just loop over the ports doing
Not very clever and I know for a fact that it doesn't work on my coworker's Ubuntu install (the same board reports manufacturer as "STMicroelectronics", i.e. without the dot at the end).
Could try some ducktyping after that I guess by sending some commands and see if the reply looks like it comes from an Espruino :)