Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to parse URC as bytes #210

Open
cacharle opened this issue Aug 28, 2024 · 3 comments
Open

Unable to parse URC as bytes #210

cacharle opened this issue Aug 28, 2024 · 3 comments

Comments

@cacharle
Copy link

cacharle commented Aug 28, 2024

I am failing to make a response struct that will parse to my desired URC:

#[derive(AtatUrc)]
pub enum Urc {
    #[at_urc("+QIND")]
    OTAStatus(OTAStatus),
}

#[derive(AtatResp)]
pub struct OTAStatus {
    bytes: heapless_bytes::Bytes<256>,
}

Gives me some of the following errors when parsing:

[ERROR] - Parsing URC FAILED: b"+QIND: \"FOTA\",\"HTTPSTART\""
[ERROR] - Parsing URC FAILED: b"+QIND: \"FOTA\",\"DOWNLOADING\",91%"
[ERROR] - Parsing URC FAILED: b"+QIND: \"FOTA\",\"HTTPEND\",0"

I have also tried to properly parse the fields of the response like so:

#[derive(AtatResp)]
pub struct OTAStatus {
    fota: heapless::String<4>, // "FOTA"
    event: heapless::String<16>, // HTTPSTART, DOWNLOADING, HTTPEND, START, UPDATING, END
    arg: Option<heapless::String<16>>, // percentage for download and update, result code for httpend and end
    status1: Option<u8>,
    status2: Option<u8>,
}

or tried to not have any fields in the struct. I always get the same errors

I am a new user of this crate so I may be missing something obvious

@cacharle
Copy link
Author

cacharle commented Aug 28, 2024

It is able to parse it if I don't specify any struct in the URC enum:

#[derive(AtatUrc)]
pub enum Urc {
    #[at_urc("+QIND")]
    OTAStatus,
}

But of course, I don't get any of the informations I want with this so it's not great.

@cacharle
Copy link
Author

cacharle commented Aug 29, 2024

Okay, looking has some previous code that could parse it, I think this specific URC is terminated by a \r instead of \r\n.

I now have #[at_urc("+QIND", termination = "\r")] but it still fails to parse.

@cacharle
Copy link
Author

Also tried to copy the default urc parser in my code and replace the \r\n by \r but it wasn't successful

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant