A question on the inverter firmware. I'm just trying to get the binary logging working on my F405 port but have been having problems in that the last few bytes of a string sent to the UART using printf() are missing. Having debugged this what I found was that printf calls putchar() which then fills a ping pong buffer and then calls SendCurrentBuffer() to transmit whenever one of the buffers is full. This then triggers a DMA to actually transmit the data.
The problem I have is that Putchar() only triggers the DMA when the outgoing DMA buffer is full. The last bit of the string is correctly written to the ping pong output buffer but because it never fills the last few bytes are never sent.
I've fixed it by adding a FlushOutput() function which forces the buffer to be sent but I can't help but think that this effect should cause problems elsewhere but can't see why it hasn't been??
What am I missing?
Edit - I'm being dim again, it's because my string doesn't end with a '\n' (newline) - flush removed and newline added!
Inverter firmware and putchar
- johu
- Site Admin
- Posts: 5791
- Joined: Thu Nov 08, 2018 10:52 pm
- Location: Kassel/Germany
- Has thanked: 157 times
- Been thanked: 1025 times
- Contact:
Re: Inverter firmware and putchar
Thou shall use Terminal::SendBinary() for sending binary data
PutChar is intended for \n delimited lines, whenever an \n occurs the buffer is sent - or when it's full.
EDIT: maybe this hasn't made it into the F4 branch, just copy it over from the F1 branch
PutChar is intended for \n delimited lines, whenever an \n occurs the buffer is sent - or when it's full.
EDIT: maybe this hasn't made it into the F4 branch, just copy it over from the F1 branch
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
-
- Posts: 1801
- Joined: Sun Apr 03, 2022 1:57 pm
- Has thanked: 102 times
- Been thanked: 347 times
Re: Inverter firmware and putchar
I am (well a modified version of it to make better use of the DMA buffer).
It was the json headers causing the problem (ascii).
Edit - still need to add an extra buffer layer though as it occasionally loses a message when the 10ms interrupt runs.
It was the json headers causing the problem (ascii).
Edit - still need to add an extra buffer layer though as it occasionally loses a message when the 10ms interrupt runs.