dbrgn / espresso

AT based driver crate for ESP8266 WiFi modules.
Apache License 2.0
9 stars 4 forks source link

Handling of responses #1

Closed dbrgn closed 4 years ago

dbrgn commented 4 years ago

For the AT command, ATAT is not processing the response...

Starting (dev=/dev/ttyUSB0, baud=115200)...
Sending command At
[2020-03-14T00:29:23Z DEBUG atat::client] Sending command: "AT\r\n"
[2020-03-14T00:29:23Z TRACE atat::ingress_manager] Ingress: Receiving 11 bytes
[2020-03-14T00:29:23Z TRACE atat::ingress_manager] Ingress: Parsing / Idle / "AT\r\r\n\r\nOK\r\n"
[2020-03-14T00:29:23Z TRACE atat::ingress_manager] Ingress: Switching to state ReceivingResponse
Result: Err(Timeout)

The echoed bytes look really strange. Maybe that's the reason?

Also, for AT+GMR, which returns quite a long string, I got this:

Starting (dev=/dev/ttyUSB0, baud=115200)...
Sending command GetFirmwareVersion
[2020-03-14T00:49:38Z DEBUG atat::client] Sending command: "AT+GMR\r\n"
[2020-03-14T00:49:38Z TRACE atat::ingress_manager] Ingress: Receiving 32 bytes
[2020-03-14T00:49:38Z TRACE atat::ingress_manager] Ingress: Parsing / Idle / "AT+GMR\r\r\nAT version:1.1.0.0(May "
[2020-03-14T00:49:38Z TRACE atat::ingress_manager] Ingress: Switching to state ReceivingResponse
[2020-03-14T00:49:38Z TRACE atat::ingress_manager] Ingress: Receiving 32 bytes
[2020-03-14T00:49:38Z TRACE atat::ingress_manager] Ingress: Parsing / ReceivingResponse / "AT version:1.1.0.0(May 11 2016 18:09:56)\r\nSDK version:1"
[2020-03-14T00:49:38Z TRACE atat::ingress_manager] Ingress: Receiving 32 bytes
[2020-03-14T00:49:38Z TRACE atat::ingress_manager] Ingress: Parsing / ReceivingResponse / "AT version:1.1.0.0(May 11 2016 18:09:56)\r\nSDK version:1.5.4(baaeaebb)\r\ncompile time:May"
[2020-03-14T00:49:38Z TRACE atat::ingress_manager] Ingress: Receiving 23 bytes
[2020-03-14T00:49:38Z TRACE atat::ingress_manager] Ingress: Parsing / ReceivingResponse / "AT version:1.1.0.0(May 11 2016 18:09:56)\r\nSDK version:1.5.4(baaeaebb)\r\ncompile time:May 20 2016 15:08:19\r\nOK\r\n"
GetFirmwareVersion: parse("AT version:1.1.0.0(May 11 2016 18:09:56)")
[2020-03-14T00:49:38Z TRACE atat::ingress_manager] Ingress: Switching to state Idle
Result: Ok(FirmwareVersion("AT version:1.1.0.0(May 11 2016 18:09:56)"))

First of all, I had to manually increase the max length parameter for get_line in the ingress manager, otherwise it panicked (64 wasn't enough).

Second, is it valid to return multiple lines all delimited by CRLF? The spec says:

Information text responses consist of three parts: a header, text, and a trailer. The characters transmitted for the header are determined by a user setting (see the V command, 6.2.6). The trailer consists of two characters, being the character having the ordinal value of parameter S3 followed by the character having the ordinal value of parameter S4. Information text specified in this Recommendation always consists of a single line; information text returned in response to manufacturer-specific commands may contain multiple lines, and the text may therefore include IA5 CR, LF, and other formatting characters to improve readability.

I'm not sure if I understand this correctly, but would the last sentence imply that S3/S4 are not CRLF, or may CRLF be repeated until the result code?

(It's possible that the ESP8266 does not conform to the spec, which would be very unfortunate...)

MathiasKoch commented 4 years ago

Ohh .. It appears you have discovered an AT case i have yet to come by :)

I will try to do a fix for multiline responses. I am pretty sure it conforms to the spec though, so it should be supported.

Regarding the length in line_len().. Yeah, i have a number of "fixed" sizes spread around, that i would like to do in a generic way, but i have not yet gotten around to it. Any suggestions on a best way to do it is welcomed.

dbrgn commented 4 years ago

Fixed by https://github.com/BlackbirdHQ/atat/pull/25 and 357636d8e028cf809f04d04190386c70c2f35d8a.