Reusing uart.c functions for a serial device

C programming, build, interpreter/VM.
Target audience: MicroPython Developers.
Post Reply
User avatar
dbc
Posts: 89
Joined: Fri Aug 28, 2015 11:02 pm
Location: Sunnyvale, CA

Reusing uart.c functions for a serial device

Post by dbc » Mon Jul 24, 2017 12:41 am

I'm working on a project with a couple of serial protocols that need to run relatively fast. I'm thinking of creating C modules that implement the protocols so that the Python interface doesn't have to keep up with the character-level protocols. Can I link against uart.c to pick up the basic uart initialization and character I/O? I'd rather not rewrite all of that stuff. Also, I thought at one point the uarts were DMA-enabled, it would be great to be able to re-use that. Any pointers?

ajie_dirgantara
Posts: 81
Joined: Fri Sep 02, 2016 9:26 am

Re: Reusing uart.c functions for a serial device

Post by ajie_dirgantara » Mon Oct 09, 2017 9:19 am

dbc wrote:I'm working on a project with a couple of serial protocols that need to run relatively fast. I'm thinking of creating C modules that implement the protocols so that the Python interface doesn't have to keep up with the character-level protocols. Can I link against uart.c to pick up the basic uart initialization and character I/O? I'd rather not rewrite all of that stuff. Also, I thought at one point the uarts were DMA-enabled, it would be great to be able to re-use that. Any pointers?
How fast does it needs? as far as I know micropython execution time is still capable to handle relatively fast baudrate (e.g. 115200). And if you need raw processing power in C, you could implement your own protocol in C, called in python after the data stream is received, without touching uart.c Leave uart.c as it is and make your serial buffer large enough so it could processed faster.

garya@arcimoto.com
Posts: 7
Joined: Mon Oct 26, 2020 6:26 pm

Re: Reusing uart.c functions for a serial device

Post by garya@arcimoto.com » Wed Dec 30, 2020 8:02 pm

Hi,
Has anyone done this before? I'm wanting to access a serial device connected to my MCU and would like to reuse the C source code library I have that communicates over a UART interface.
Here is my high-level design
micropython <-> micropy_interface <-> existing C library <-> C-based uart interface <-> hardware.

I'd rather not port the C library over to micropython just because it's all working and tested on a Windows OS. Maintaining two code repos and syncing them can be a burden.

Thanks much for any help, it is greatly appreciated.

User avatar
jimmo
Posts: 2072
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: Reusing uart.c functions for a serial device

Post by jimmo » Mon Jan 11, 2021 12:21 am

garya@arcimoto.com wrote:
Wed Dec 30, 2020 8:02 pm
Has anyone done this before?
We use this for the BLE HCI driver on STM32.

Which port are you using?

Post Reply