FactbirdHQ / atat

no_std crate for parsing AT commands
Apache License 2.0
109 stars 29 forks source link

Async client #142

Closed rmja closed 1 year ago

rmja commented 1 year ago

This PR adds an async atat client. It incurs some major changes to the current project structure, so it should be merged with care.

There are some outstanding issues:

MathiasKoch commented 1 year ago

Async is a protected keyword in rust, so the Convention is to use asynch

mvniekerk commented 1 year ago

Hi @rmja I've pulled in your changes into my fork (https://github.com/mvniekerk/atat/)

https://github.com/mvniekerk/moko-mkl62ba-embassy/blob/ba9299dce32dc9fff98d0ded83524072fc018d9b/examples/pico-uart/src/main.rs#L87

The safe buffer size guard seems not to be working. Would've been cool if it did though.

In essence, I've done this:

const INGRESS_BUF_SIZE: usize = RX_SIZE;
const RES_CAPACITY: usize = 2 * (INGRESS_BUF_SIZE + 3) + 1;

Which means the code on /atat/src/buffers.rs


    pub const fn is_valid_res_capacity<const INGRESS_BUF_SIZE: usize, const RES_CAPACITY: usize>(
    ) -> bool {
        RES_CAPACITY >= 2 * (BBQUEUE_FRAME_HEADER_SIZE + RES_FRAME_DISPATCH_SIZE + INGRESS_BUF_SIZE)
    }

Should've evaluated as true (it doesn't). Unless I'm missing something?

rmja commented 1 year ago

@mvniekerk

It turns out that the issue has to do with the way the new is called:

    static buffers_work: Buffers<Urc, 500, 1010, 10, 1> =
        Buffers::<Urc, 500, 1010, 10, 1>::new();

    static buffers_does_not_work: Buffers<Urc, 500, 1010, 10, 1> =
         Buffers::new();

Apparently one needs to be explicit about the turbofish when calling new.

mvniekerk commented 1 year ago

Seems like a compiler error then...

Groete / Best regards Michael van Niekerk


Van: Rasmus Melchior Jacobsen @.> Gestuur: Monday, March 20, 2023 9:58:56 AM aan: BlackbirdHQ/atat @.> Aa: Michael van Niekerk @.>; Mention @.> onderwerp: Re: [BlackbirdHQ/atat] Async client (PR #142)

@mvniekerkhttps://github.com/mvniekerk

It turns out that the issue has to do with the way the new is called:

static buffers_work: Buffers<Urc, 500, 1010, 10, 1> =
    Buffers::<Urc, 500, 1010, 10, 1>::new();

static buffers_does_not_work: Buffers<Urc, 500, 1010, 10, 1> =
     Buffers::new();

Apparently one needs to be explicit about the turbofish when calling new.

— Reply to this email directly, view it on GitHubhttps://github.com/BlackbirdHQ/atat/pull/142#issuecomment-1475770931, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AAL7O7YV4NZTOFQ6L7NTFXDW5AE4BANCNFSM6AAAAAAVB5YF6E. You are receiving this because you were mentioned.Message ID: @.***>

rmja commented 1 year ago

Either that, or you need to define #![feature(generic_const_exprs)] in main.rs. If you do that, then the second one will also work.

mvniekerk commented 1 year ago

I've tested adding the params, it worked. Thanks @rmja

MathiasKoch commented 1 year ago

@rmja Ready to merge this, so we can add a followup PR with the pubsub URC handling, and code-size optimizations?

rmja commented 1 year ago

Really nice. Yes!

MathiasKoch commented 1 year ago

Will you rebase, and open the followup PR? :)