new UART characteristic write for each new line in forEach loop #6735
Replies: 1 comment
-
Posted at 2023-10-04 by @fanoush It is unlikely to work the way you want. There is a MTU limit so data is split into 'random' packets. So you may not get complete line in one write/notification anyway due to that. Can't you just add what you get to some string/buffer and then just parse and remove complete line(s) from beginning of that line by line? Posted at 2023-10-04 by nravanelli @fanoush I had been doing that method originally (storing in string/buffer), but missing packets had became an issue that I wrestled with, so I wanted to assess whether I could venture down a "new line only" option for each write/notification. Assuming that I could control/have a greater MTU size... would sending each iteration as a new write/notification be possible? Posted at 2023-10-04 by @fanoush missing packets? that's very strange and should not happen. However you mean that you would really not mind missing complete lines from the output if it was sent line by line? I don't know if there is something like Bluetooth.flush() or some character to write that would do it, maybe not. If not then splitting the loop so it goes to idle loop after each line could help. Like scheduling each write line via setTimeout can you try something like
Posted at 2023-10-05 by @gfwilliams I did add So it's possible that doing But really the UART in Espruino was designed specifically to avoid sending more packets than needed, so if you want fine-grained control it might be worth making your own characteristics Posted at 2023-10-06 by nravanelli Thanks Gordon for the suggestions and clarification. I think the missing issue with my current implementation is the end carriage the UART in Espruino uses. If not mistaken, it’s simply Posted at 2023-10-06 by @gfwilliams Ahh - no, Basically the REPL (the thing you can type JS into to execute it) is still on the UART. So there's a prompt
If you use But if you use Depending on what you have planned you can move the console out the way with Posted at 2023-10-06 by nravanelli Gotcha, this makes sense. I have no reverted to the following:
Which after execution, should always print Posted at 2023-10-09 by @gfwilliams
Yes, ish. Although in a way if you really do need to mark the end of what you're sending then just adding a The reason is, if you had some other code running in an event like |
Beta Was this translation helpful? Give feedback.
-
Posted at 2023-10-04 by nravanelli
I am trying to send a new line of data over UART BLE for each iteration of the following command that is sent to the device;
However, it gets concatenated together and sent as data in one write characteristic. I would like each iteration to be a separate (new) BLE write characteristic/notification. How could I do that so I get new data for each iteration of the loop?
Beta Was this translation helpful? Give feedback.
All reactions