-
-
Gordon, thank you. I could not get it to work. I will be away 3 days.
I was seeking a solution to get this simple test snippet to run, when not connected to a USB port of a computer. As I understood, the Serial port will be on USB by default. And on Serial1 by Default if unplugged. So this blocks my device (HM10). So I would like to set to USB or Serial2. I could not get it to work. I ll check later on it.Serial=Serial1 Serial.setup(9600); Serial.on('data', function (data) { console.log(data); if (data==='1'){ LED1.write(1); Serial.print("test\n"); } if (data==='0'){ LED1.write(0); } if (data==='d'){ LED2.write(1); Serial.print("sensor: t="+temp_act+", p="+press_act+", h="+hum_act); LED2.write(0); }
-
-
-
-
-
-
-
-
I just noticed, the SIM900 library is memory leaking, maybe du networkJS.create(netCallbacks).
Upon a repetive call on reconnect old references aren't getting collected with garbage collection, I assume old references are still being kept externally.
Could this issue be due to the networkJS library? Or is it due the SIM900 library only? -
I updated my version to get rid of self caused memory leaks, I use the immediate return for timeouts. Thanks to the fix to the SIM900 module it is so far quite stable.
Additionally I set the SIM900 baud rate to 9600. Additionally I pull jobs out of resources with the max=1 parameter, means get only as less data as possible.
Memory seems stable so far.
I put the code online: https://github.com/afitterling/espruino-projects2/blob/master/RemoteWateringSystem.js
The cariots module can now handle wrong JSON and will reject the successful call:
https://github.com/afitterling/Espruino-Modules/blob/develop/carriots.js
this is the result of the status push at call 104.{ "stats": { "process": { "stackEndAddress": 536959420, "flash_binary_end": 376280, "flash_code_start": 134234112, "free": 2875, "flash_length": 393216, "usage": 2225, "total": 5100, "flash_start": 134217728, "history": 1753 }, "errorFlags": [], "requests": 104, "errors": 0, "resets": 1 } }
-
i am experienced with garbage collection issues, it should theoretically never be the case to run out of memory if constantly destroying references my self carefully. also not json is an isue as after processing the objects are nulled.
i may have to rething the overall model of that piece of hardware.
-
@allObjects the blownup json is due mainly of infrastructure. carriots is a great iot platform. of course i can write the whole platform myself and being leaner. but i rely on such infrastructure for inter device communication. i like there way. i think the espruino device should be capable of handling such simple things. the productive response data is a bit leaner just carrying two values, cycle (watercycle) and time. also i use the max param to limit the get to one response entry at a time.
carriots doesnt represent a full schema but all you need to be able to handle different devices and logik. one optimization point can be to put the logic into carriots and have not a autonomous device anymore.
the overhead to deal with csv isnt really an advantage.
-
@jonreid yes, i knew about it and my status post requests are publishing the memory free. may i ask how do you reboot? what command?
hm... my code is not that big, actually at any point there shouldn't be a less memory state. i even taking care about intervals and timeout myself. it might due to memory leaking somewhere else.
-
I think @Gordon is right:
"FIFO_FULL", "LOW_MEMORY" ] } } } Uncaught SyntaxError: Got ID:total_documents expected ',' at line 3 col 3 {"total_documents":3,"result":[{"_id":"579bc6ad5c5d751b7e537... ^ in function called from system
-
-
Amazinly doing so.. it seems to works! I just put the max=1 param out. As of today a collection length of >3 broke that.
@Gordon To the FIFO issue.... may it be a wrong canditate. I was noticing, the E.getErrorStats always returns FIFO_full on any request. But it is going to be erased later on.
Anyway the SIM900 driver is of really great help!> $http({ : host: 'api.carriots.com', : path: '/streams/', : port: '80', : method: 'GET', : params: { : _t: 'str', : device: 'Commander@afitterling.afitterling', : max: 10 : } : }).then(function(res){ a=res}) { "host": "api.carriots.com", "path": "/streams/?_t=str&device=Commander@afitterling.afitterling&max=10", "port": "80", "method": "GET", "headers": { "Content-Type": "application/json", "carriots.apiKey": "xxxxxxxxx", "Content-Length": 0 } } null ={ } > > OK > 0, CONNECT OK > > > > 0, SEND OK > + RECEIVE,0,1380: HTTP/1.1 200 OK Dat e: Fri, 29 Jul 2016 20:55:58 GMT Content-Type: applicatio n/vnd.carriots.v2+json; charset=utf-8 Conne ction: close Server: Carriots REST API Ca che-Control: no-cache Allow: GET, POST Access-Con trol-Allow-Origin: * Access-Control-Allow-Credentia ls: true Access-Control-Expose-Headers: Dat e,Server,Allow,Connection,Content-Length,Con tent-Type,Cache-Control {"total_do cuments":6,"result":[{"_id":"579bc2385c5d75660953772e","protocol ":"v2","checksum":"","_t":"str","at":1 469825592,"device":"Commander@afitterl ing.afitterling","data":{"This":"Is a JSO N example","Carriots":{"text":"Hello World" ,"number":123,"cool":true}},"id_developer":"8c19 07cf2402f422b64069832d07aa47276a6414fd4fdcf558a96f6a9 13c0a14@afitterling.afitterling","created_at":1469825592,"o wner":"afitterling"},{"_id":"579bc2435c5d75a007537738","protocol":"v2 ","checksum":"","_t":"str","at":1469825603,"device":"Commander@afitterling.afitt erling","data":{"This":"Is a JSON example","Carriots":{"text":"Hello World","number":123,"cool": true}},"id_developer":"d98688e13aae2861be6dd0bed33ba44f4d9171dfbe90d4ed64f5c091bb624cf4@afitterling.afitterling","crea ted_at":1469825603,"owner":"afitterling"},{"_id":"579bc24c5c5d755102537814","protocol":"v2","checksum":"","_t":"str","at":1469825612,"device":"Commande r@afitterling.afitterling","data":{"This":"Is a JSON example","Carriots":{"text":"Hello W +RECEIVE,0,1339: orld","number":123,"cool":true}},"id_developer":"6ddc5cab0331a2505419eb9d08afd74e2c31cc35c4 185d6e7de98f89b0655aed@afitterling.afitterling","created_at":1469825612,"owner":"afitterling"},{"_id":"579bc2bc5c5d751b7e537889","protocol":"v2","checksum":"","_t":"str","at":1469825724,"device":"Commander@afitterling.afitterling","data":{"This":"Is a JSON example","Carriots":{"text":"Hello Wor ld","number":123,"cool":true}},"id_developer":"c1564b155fa18858c1f608f4db64f359e6539d ec9789d51f14576c2819b6788e@afitterling.afitterling","created_at":1469825724,"owner": "afitterling"},{"_id":"579bc2c75c5d75d908537723","protocol":"v2","checksum":"","_t":"str","at":1469 825735,"device":"Commander@afitterling.afitterling","data":{"This":"Is a JSON example","Carriots":{"text":"Hello World","n umber":123,"cool":true}},"id_developer":"0a1e227e3914808240d4b29385fcc426f8dca235cce0295db059e41433a81a8a@afitterling.afitterling","created_at":1469825735,"o wner":"afitterling"},{"_id":"579bc2d25c5d75f87f537843","protocol":"v2","checksum":"","_t":"str","at":1469825746,"device":"Commander@afitterling.afitterling","data":{"This":"Is a JSON example","Carriots":{"text ":"Hello World","number":123,"cool":true}},"id_developer":"e148352107e64d155ed2f32511afb197717f9d1f0e3e537773d0376ec1d0fec6@afitterling.afitterling","created_at":1469825746,"owner":"afitterling"}]} > 0 , CLOSED >a ={ "total_documents": 6, "result": [ { "_id": "579bc2385c5d75660953772e", "protocol": "v2", "checksum": "", "_t": "str", "at": 1469825592, "device": "Commander@afitterling.afitterling", "data": { "This": "Is a JSON example", "Carriots": { "text": "Hello World", "number": 123, "cool": true } }, "id_developer": "8c1907cf2402f422b" ... "rling.afitterling", "created_at": 1469825592, "owner": "afitterling" }, { "_id": "579bc2435c5d75a007537738", "protocol": "v2", "checksum": "", "_t": "str", "at": 1469825603, "device": "Commander@afitterling.afitterling", "data": { "This": "Is a JSON example", "Carriots": { "text": "Hello World", "number": 123, "cool": true } }, "id_developer": "d98688e13aae2861b" ... "rling.afitterling", "created_at": 1469825603, "owner": "afitterling" }, { "_id": "579bc24c5c5d755102537814", "protocol": "v2", "checksum": "", "_t": "str", "at": 1469825612, "device": "Commander@afitterling.afitterling", "data": { "This": "Is a JSON example", "Carriots": { "text": "Hello World", "number": 123, "cool": true } }, "id_developer": "6ddc5cab0331a2505" ... "rling.afitterling", "created_at": 1469825612, "owner": "afitterling" }, { "_id": "579bc2bc5c5d751b7e537889", "protocol": "v2", "checksum": "", "_t": "str", "at": 1469825724, "device": "Commander@afitterling.afitterling", "data": { "This": "Is a JSON example", "Carriots": { "text": "Hello World", "number": 123, "cool": true } }, "id_developer": "c1564b155fa18858c" ... "rling.afitterling", "created_at": 1469825724, "owner": "afitterling" }, { "_id": "579bc2c75c5d75d908537723", "protocol": "v2", "checksum": "", "_t": "str", "at": 1469825735, "device": "Commander@afitterling.afitterling", "data": { "This": "Is a JSON example", "Carriots": { "text": "Hello World", "number": 123, "cool": true } }, "id_developer": "0a1e227e391480824" ... "rling.afitterling", "created_at": 1469825735, "owner": "afitterling" }, { "_id": "579bc2d25c5d75f87f537843", "protocol": "v2", "checksum": "", "_t": "str", "at": 1469825746, "device": "Commander@afitterling.afitterling", "data": { "This": "Is a JSON example", "Carriots": { "text": "Hello World", "number": 123, "cool": true } }, "id_developer": "e148352107e64d155" ... "rling.afitterling", "created_at": 1469825746, "owner": "afitterling" } ] } >
-
in the above log from the example it looks like that the response string itself handed into JSON.parse is not valid json anymore. It has passages like:
e":"Commander@afitterling.afitterlinÂg","data":{"This":"Is a JSON example","Carriots":{"texfitterli ] "+D,0,900:t\":\"str\",\"at\"
So I came to the conclusion the SIM900 mixed it up(?)
-
-
I am using the Pico board.
I run it currently over usb but additionally with an external power supply, as the usb connection is only for debugging purpoises. I sometimes pull off usb.If the document gets parsed by one the total_document is there every time. If however the document getting JSON parsed is only truncated this is missing.
I could successfully reproduce that the error occurs only if a certain treshold of response length is tresspassed. And the response string from the hardware seems truncated.
I looks as if it receives only a limited amount of bytes? But there is only one callback? So my assumption was the callback gets called with an incomplete set of data, that itself will be passed in to the callbacks/promises.A good thing. As I understood now at least the source of error, I could so far fix it with the max param that carriots provides. I pick only one job at a time. If this works for 7d/24h I'll be glad. My garden is in a remote area very far away. :-)
-
-
-
I accidentally also put my debug output from the request in their above? Should I take it out.
only the lines:{ "host": "api.carriots.com", "path": "/streams/?_t=str&device=Commander@afittÂerling.afitterling", "port": "80", "method": "GET", "headers": { "Content-Type": "application/json", "carriots.apiKey": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxÂ", "Content-Length": 0 } } null
-
Hi Gordon, thanks again for you support. I have only limited time today. Only, if you have time.
I am looking forward for your expert statement.>requestsNew() =undefined > ] "\r\n" <--- "\r\n" 10.228.192.245 ] "10.228.192.245\r\n" <--- "10.228.192.245\r\n" { "host": "api.carriots.com", "path": "/streams/?_t=str&device=Commander@afitterling.afitterling", "port": "80", "method": "GET", "headers": { "Content-Type": "application/json", "carriots.apiKey": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", "Content-Length": 0 } } null ["AT+CIPSTART=0,\"TCP\",\"api.carriots.com\",80\r\n" > OK ] "\r\nOK\r\n" <--- "\r\nOK\r\n" > 0, CONNEC ] "\r\n0, CONNEC" <--- "\r\n0, CONNEC" T OK ] "0, CONNECT OK\r\n" <--- "T OK\r\n" > > ] "\r\n> " <--- "\r\n> " > 0, SEND O ] "\r\n0, SEND O" <--- "\r\n0, SEND O" K ] "0, SEND OK\r\n" <--- "K\r\n" > +RECEIVE, ] "\r\n+RECEIVE," <--- "\r\n+RECEIVE," DEBUG: +RECEIVE, 0,1380: HTTP/1.1 200 OK Date: Fri, 29 Jul 2016 07:46:50 GMT Content-Type: application/vnd.carriots.v2+json; charset=utf-8 Connection: cl ] "+RECEIVE,0,1380:\r\nHTTP/1.1 200 OK\r\nDate: Fri, 29 Jul 2016 07:46:50 GMT\r\nContent-Type: application/vnd.carriots.v2+json; charset=utf-8\r\nConnection: cl" <--- "0,1380:\r\nHTTP/1.1 200 OK\r\nDate: Fri, 29 Jul 2016 07:46:50 GMT\r\nContent-Type: application/vnd.carriots.v2+json; charset=utf-8\r\nConnection: cl" DEBUG: +RECEIVE,0,1380: HTTP/1.1 200 OK Date: Fri, 29 Jul 2016 07:46:50 GMT Content-Type: application/vnd.carriots.v2+json; charset=utf-8 Connection: cl ose Server: Carriots REST API Cache-Control: no-cache Allow: GET, POST Access-Control-Allow-Origin: * Access-Control-Allow-Credentials: true Access-Control-Expose-Headers: Date,Server,Allow,Connection,Content-Length,Content-Type,Cache-Control {"total_documents":3,"result":[{"_id":"579b07af5c5d750a2e53769a","protocol":"v2","checksum":"","_ ] "+D,0,1249:ose\r\nServer: Carriots REST API\r\nCache-Control: no-cache\r\nAllow: GET, POST\r\nAccess-Control-Allow-Origin: *\r\nAccess-Control-Allow-Credentials: true\r\nAccess-Control-Expose-Headers: Date,Server,Allow,Connection,Content-Length,Content-Type,Cache-Control\r\n\r\n{\"total_documents\":3,\"result\":[{\"_id\":\"579b07af5c5d750a2e53769a\",\"protocol\":\"v2\",\"checksum\":\"\",\"_" <--- "ose\r\nServer: Carriots REST API\r\nCache-Control: no-cache\r\nAllow: GET, POST\r\nAccess-Control-Allow-Origin: *\r\nAccess-Control-Allow-Credentials: true\r\nAccess-Control-Expose-Headers: Date,Server,Allow,Connection,Content-Length,Content-Type,Cache-Control\r\n\r\n{\"total_documents\":3,\"result\":[{\"_id\":\"579b07af5c5d750a2e53769a\",\"protocol\":\"v2\",\"checksum\":\"\",\"_" t":"str","at":1469777839,"device":"Commander@afitterling.afitterling","data":{"This":"Is a JSON example","Carriots":{"text":"Hello World","number":123,"cool":true}},"id_developer":"20bab0871682e6f1f2724a2753a83c3b959af6088165e2abf88dfa045ebac8a0@afitterling.afitterling","created_at":1469777839,"owner":"afitterling"},{"_id":"579b07b85c5d75792d5376c2","protocol":"v2","checksum":"","_t":"str","at":1469777848,"device":"Commander@afitterling.afitterling","data":{"This":"Is a JSON example","Carriots":{"texfitterli ] "+D,0,900:t\":\"str\",\"at\":1469777839,\"device\":\"Commander@afitterling.afitterling\",\"data\":{\"This\":\"Is a JSON example\",\"Carriots\":{\"text\":\"Hello World\",\"number\":123,\"cool\":true}},\"id_developer\":\"20bab0871682e6f1f2724a2753a83c3b959af6088165e2abf88dfa045ebac8a0@afitterling.afitterling\",\"created_at\":1469777839,\"owner\":\"afitterling\"},{\"_id\":\"579b07b85c5d75792d5376c2\",\"protocol\":\"v2\",\"checksum\":\"\",\"_t\":\"str\",\"at\":1469777848,\"device\":\"Commander@afitterling.afitterling\",\"data\":{\"This\":\"Is a JSON example\",\"Carriots\":{\"texfitterli" <--- "t\":\"str\",\"at\":1469777839,\"device\":\"Commander@afitterling.afitterling\",\"data\":{\"This\":\"Is a JSON example\",\"Carriots\":{\"text\":\"Hello World\",\"number\":123,\"cool\":true}},\"id_developer\":\"20bab0871682e6f1f2724a2753a83c3b959af6088165e2abf88dfa045ebac8a0@afitterling.afitterling\",\"created_at\":1469777839,\"owner\":\"afitterling\"},{\"_id\":\"579b07b85c5d75792d5376c2\",\"protocol\":\"v2\",\"checksum\":\"\",\"_t\":\"str\",\"at\":1469777848,\"device\":\"Commander@afitterling.afitterling\",\"data\":{\"This\":\"Is a JSON example\",\"Carriots\":{\"texfitterli" ng"},{"_id":"579b093a5c5d750a2e5376bc","protocol":"v2","checksum":"","_t":"str","at":1469778234,"device":"Commander@afitterling.afitterling","data":{"This":"Is a JSON example","Carriots":{"text":"Hello W +RECEIVE,0,187: orld","number":123,"cool":true}},"id_developer":"4aaed914017f667ecf933be52e147111d3b0b12460c7eff8d41e35b6164b31c6@afitterling.afitterling","created_at":1469778234,"owner":"afitterling"}]} ] "+D,0,387:ng\"},{\"_id\":\"579b093a5c5d750a2e5376bc\",\"protocol\":\"v2\",\"checksum\":\"\",\"_t\":\"str\",\"at\":1469778234,\"device\":\"Commander@afitterling.afitterling\",\"data\":{\"This\":\"Is a JSON example\",\"Carriots\":{\"text\":\"Hello W\r\n+RECEIVE,0,187:\r\norld\",\"number\":123,\"cool\":true}},\"id_developer\":\"4aaed914017f667ecf933be52e147111d3b0b12460c7eff8d41e35b6164b31c6@afitterling.afitterling\",\"created_at\":1469778234,\"owner\":\"afitterling\"}]}" <--- "ng\"},{\"_id\":\"579b093a5c5d750a2e5376bc\",\"protocol\":\"v2\",\"checksum\":\"\",\"_t\":\"str\",\"at\":1469778234,\"device\":\"Commander@afitterling.afitterling\",\"data\":{\"This\":\"Is a JSON example\",\"Carriots\":{\"text\":\"Hello W\r\n+RECEIVE,0,187:\r\norld\",\"number\":123,\"cool\":true}},\"id_developer\":\"4aaed914017f667ecf933be52e147111d3b0b12460c7eff8d41e35b6164b31c6@afitterling.afitterling\",\"created_at\":1469778234,\"owner\":\"afitterling\"}]}" > 0, CL ] "wner\":\"afitterling\"}]}\r\n0, CL" <--- "\r\n0, CL" OSED ] "0, CLOSED\r\n" <--- "OSED\r\n" Uncaught Error: Field or method "total_documents" does not already exist, and can't create it on undefined at line 1 col 614 ..."Carriots":{"texfitterling"},{"_id":"579b093a5c5d750a2e5376b... ^ in function called from system at line 208 col 33 total_docs: data.total_documents ^ in function called from system >E.getErrorFlags() =[ "FIFO_FULL" ] >
It was my fault. The declination outside of init Serial=Serial1 blocked the USB.setConsole command.