-
-
-
Yes this is as well part of the problem. My close handlers are not getting called if the line starts with \r\n or \r or \n. See here:
var handler = function(d) { var s; if(d === 'OK') { s = sckt; at.registerLine(s + ', CONNECT OK', function() { at.unregister(s + ', CONNECT OK'); socks[s] = true; }); at.registerLine(s + ', CLOSED', function() { at.unregisterLine(s + ', CLOSED'); socks[s] = undefined; }); } }; at.cmd('AT+CIPSTART='+sckt+',"TCP",'+JSON.stringify(host)+','+port+'\r\n', 10000, handler);
This unfortunately happens sometimes, for example a few seconds ago I had the situation:
] "\r\n1, CLOSED\r\n" <--- "\r\n1, CLOSED\r\n"
The close handler has not been called here :(
-
-
Hi Gordon... It is annoying... Again problems with GPRS. When the sim900 is ready for receiving data after AT+CIPSEND it sends:
] "\r\n> "
When I use the following code:
at.register('> ', function() { at.unregister('> '); at.write(data); return ""; });
It removes the "> " from the AT buffer but leaves "\r\n" in it which can cause problems for subsequent requests (maybe for the +RECEIVE handler as well). I tried as well to register for "\r\n> ". That didn't solve that for me. How would you handle that? There are as well situations like
] "\r" <--- "\r" ] "\n> " <--- "\n> "
or
["AT+CIPSEND=1,26\r\n" ] "\r\n>" <--- "\r\n>" ] "> " <--- " "
-
-
-
Hello Gordon,
I tried to solve it like this yesterday night:
/* Send data. Returns the number of bytes sent - 0 is ok. Less than 0 */ send: function(sckt, data) { if (busy || at.isBusy() || socks[sckt]=="Wait") return 0; if (!socks[sckt]) return -1; // error - close it busy = true; at.register('>', function() { console.log('READY'); at.unregister('>'); at.write(data); return ""; }); at.registerLine(sckt + ', SEND OK', function() { at.unregisterLine(sckt + ', SEND OK'); busy = false; return ""; }); at.cmd('AT+CIPSEND='+sckt+','+data.length+'\r\n'); at.debug(); return data.length; } };
But for some reason I ran into a deadlock situation where busy was set to true but no SEND OK came in to remove it in some cases.
I will try your solution without waiting for SEND OK and give you a feedback.
-
Hello Gordon,
I have a problem with the use of at.register('>') in the following code of the GPRS driver:
send: function(sckt, data) { if (at.isBusy() || socks[sckt]=="Wait") return 0; if (!socks[sckt]) return -1; // error - close it var f = function(d) { at.unregister('>'); if (d != sckt + ", SEND OK") return; }; at.register('>', function() { at.write(data); return ""; }); at.cmd('AT+CIPSEND='+sckt+','+data.length+'\r\n', 10000, f); return data.length; }
How can it handle multiple sockets with it? In the AT lib I can just register for some chars once. The next call of the send function for another (or for the same) socket tries to register for '>' again or sends a new AT+CIPSEND without waiting for ">" which leads the communication to an inconsistent state. I tried to set the socket to "Wait" until ">" comes in for the particular socket, but requests for other sockets were still able to send.
In the ESP8266 driver the problem was not existing because you send the data directly after AT+CIPSEND, which is - unfortunately - not working with the SIM900.
Do you have an idea how to solve the problem?
Best,
Tobias
-
-
-
-
I solved the problem !!!! I didn't see that I swapped MISO and MOSI in my wiring... I saw it in the code that there must be something wrong. :)
The strange thing is that it worked with
var spi = new SPI(); spi.setup({mosi:B14,miso:B15,sck:B13}); E.connectSDCard(spi, A8);
but not with
SPI2.setup({mosi:B14,miso:B15,sck:B13}); E.connectSDCard(spi, A8);
Thank you so much for your patience and for your help Gordon!
-
It just shows the message "ERROR: Unable to mount SD card : NOT_READY" nothing else. It is not saying anything about a missing configuration. When I do an E.connectSD it works as in the other build.
I checked that I don't use the pins for something else. Is there maybe a parameter that I missed in the build settings?
-
I had the following config:
'SD' : { 'pin_cs' : 'A8', 'pin_di' : 'B15', 'pin_do' : 'B14', 'pin_clk' : 'B13' }
The platform_config.h defines are looking good as well:
#define SD_CS_PIN 8/* A8 /
#define SD_DI_PIN 30/ B15 /
#define SD_DO_PIN 29/ B14 /
#define SD_CLK_PIN 28/ B13 */
#define SD_SPI EV_SPI2 -
-
-
I created my own build now for solving the Serial1 problem. As well I experienced that the DISK_ERR is not related to this line (beside the other problem I had):
if (process.env.CONSOLE=="Serial1") setConsole(LoopbackA);
I am currently able to solve it by just setting some interval. The following line helps as well:
setInterval(function() { /* do nothing */ }, 1000);
Do you think it could be a problem with the software SPI when the Espruino goes in sleep mode?
UPDATE: Is there a possibility to set the SD card settings in the build settings for the Pico as well? I saw there is a DEVICES section in the script for the regular Espruino. Can I use that in the script for the pico for the SD card as well?
-
-
If I use the device just without USB it seems to be working (I am not 100% sure because I can't see any logs) but when it is connected I get the DISK_ERR and some weird characters in the console. You told me that USB.setConsole() in onInit should do it. But this didn't help. With the lines above this problems are not coming up.
Did you see the warning message I put in the update of my post? Why does that come up after a while?
Best,
Tobias
-
Sorted it out. But I am not happy with the solution.
The problem was Serial1. The sim900 board was sending some bytes while the interpreter was executing some code. Unfortunately the bytes haven't been sent just to USB. It has been sent to the interpreter as well, which was confusing the code execution.
This code piece in onInit() did it:
setInterval(function() { if (process.env.CONSOLE=="Serial1") setConsole(LoopbackA); }, 1000);
As well after some time this code piece produces the following warning:
WARNING: Unable to create string as not enough memory
Unfortunately I soldered the wires for connecting the sim900 to the Serial1 pins. Is there a way to set Serial2 to be the default fallback serial port when USB is not connected (maybe in some build parameters for the firmware)? I would be happy with disabling this feature totally as well.
Best,
Tobias
-
-
It is a little bit strange. When I upload the code and write save() in the console. Everything is working well. But when I call reset(); and load(); then I get DISK_ERR, but not directly.
I do the following:
function onInit() { var spi = new SPI(); spi.setup({mosi:B14,miso:B15,sck:B13}); E.connectSDCard(spi, A8); eval(require('fs').readFile('code.js')); }
In the code.js there are subsequent file access routines.
-
@Gordon : I have to say thank you for the great support!