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

Fix AT driver #180

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Fix AT driver #180

wants to merge 1 commit into from

Conversation

Marekkon5
Copy link

The AT driver was very unreliable, sending only partial commands on Quectel devices. This patch seems to fix it for the most part.

Copy link
Contributor

@CoelacanthusHex CoelacanthusHex left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Partially writing is not related to this change completely. That's because fopen() produces a buffered IO. The case and solution have been discussed at #167

@@ -55,7 +55,7 @@ static int apdu_interface_connect(struct euicc_ctx *ctx)
device = "/dev/ttyUSB0";
}

fuart = fopen(device, "r+");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's strange. The "b" flag is a no-op on the POSIX system. It only affects Windows and lets it disable special handling of '\n' and '\x1A'.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although I am unfamiliar with inner workings of the fopen/fread family of functions, this solved the communication issues in my case on Linux. Might've been just luck or some other side effect fixing it. Feel free to close this PR if you don't think this is the real fix.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The "b" flag is a no-op on the POSIX system because POSIX has no special handling of '\n' and '\x1A' like Windows. It always behaves like Windows with a "b" flag.
https://github.com/bminor/glibc/blob/c2567b18fd77da9d4a270b20232f12616763bf76/libio/fileops.c#L262-L264
Adding setbuf(fuart, NULL) after fopen() should fix this problem. You can try it and update the PR.

@septs septs requested a review from CoelacanthusHex January 5, 2025 07:43
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

Successfully merging this pull request may close these issues.

2 participants