-
Notifications
You must be signed in to change notification settings - Fork 27
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
How to port "readable" #59
Comments
Hi sagonzal, thank you for the kind words.
Look for instance how it is done for the [arduino](https://github.com/Overdrivr/Telemetry-arduino/blob/master/src/transport.h] The exact function you need to call to get this amount depends on the UART library you are using (or maybe coded yourself) for the K22F. Is this helpful ? |
OK, so you say to use the hardware FIFO and readable returns the chars in the hardware FIFO, right? |
No, |
Would it be all right if it only returned 1, when a single byte is in the hardware FIFO ? |
Nope, it's fine :) It will just read a single byte every time It will just take more time for your incoming commands to be decoded as you might have guessed. The only issue you can face is in case you send commands too quickly, the FIFO may be written faster than read, and characters can be overwritten, causing decoding issues. |
Actually, on the arduino code, this is already what I have done, since it's easier to fetch characters from the FIFO one at a time (no arrays to deal with) |
Sadly, it is still not working. Help me going over the steps requiring sending a byte from host to the embedded: First on the start up of the embedded routine, what I do is:
Then, every time I go to a routine in the main loop I do:
in order to bring to the embedded the updated variable, uc_control, in this case. Then on the pyTelemetryCLI I issue: :> pub --u8 Kp 1 in order to publish to the embedded. In the embedded the 'update_telemetry' routine receives the characters. Two characters are in fact, a preamble byte like 0xF0 and the 0x01. But then 'amount' is always 1 and the routine goes to 'feed()' and nothing happens since transportPtr->read(&c,1) in update_telemetry(). What I'm doing wrong ? |
First, you seem to be using syntax from different versions of telemetry.
How many characters do you receive in total ? The frame should start by 0xF7 Afterward you should receive
You could get 1~2 byte extra for escaping it the frame contains 0x7D somewhere, although pretty unlikely for such a small frame. So, to debug your problem, you can:
|
Dear Rémi, version is #define TELEMETRY_VERSION_MAJOR 2 so, yes, 2.0.0 Yes i get a warning message and I can call the function update_telemetry(), no problems in that side. And the framing stars OK and then it comes the 0x01 but the breakpoints it may be breaking the code flow in the framing. Allow me to try this. Thank you in advance. |
Dear Rémi, unfortunately I still have a several byte arriving staring with is 0xF7. But the main issue, I think, is that EOF is not arriving at all: Let me show you the stats command before two writes and after it: :> stats As you can see it seems to send 20 bytes, and not 22 could it be the CLI ? |
It's actually worse than that, because two frames were sent, so I was expecting Could you open the generated logs folder (created where you started the
I will investigate on my side also Thanks |
Sorry, made a mistake when describing the protocol. So the complete frame should be
Which is consistent with your log data (tx_bytes is the count of absolutely all characters). I have checked, both pytelemetry and Telemetry return the same frame with those parameters: (hex format)
So in the log, you should see
If you can confirm it, it most likely means the issue is on the other side. Thanks a lot |
Let me see, on the 'out' log: 2016-11-18 10:31:46,698 | INFO | b'01004b7000010926' ...so it clear that it is sending, right ? Now the breakpoint, should it be on line 131 ? since it is after a return. |
You can place it on line 129, although it should not enter the if condition unless there was some memory allocation issue, which is unlikely. Yes the data has been sent correctly, so it's most likely due to the microcontroller. |
Sorry Rémi, but I do not have any transport.h and driver.h is just almost a wrapper to point to my actual uart functions. The funny thing about this is that I start receiving OK but somehow the message is broken somewhere. I'm starting to think this is a timing issue since you don't process the whole message but you prefer to feed it a byte a t a time. In hat case, in update_telemetry(): uint32_t amount = transportPtr->readable(); Why you chose to accept 'amount' to be any byte number but you force read(&c,1) reading byte by bye ? |
The RX buffer is read 1 by 1 because the decoding function works on 1 byte at a time. This is required by the escaping algorithm for frame delimiting. But I kept the If you believe there is a timing issue, then it's related to the UART driver not buffering enough received characters. Usually, default hardware drivers will buffer very few characters, and a larger software buffer must be implemented almost always. This is done on arduino, on mbed, etc. This was also the case for the Kinetis KL25Z I used for most testings. The buffering is not done by Telemetry because first I want to keep RAM consumption as low as possible, and because like I said it is sometimes already done by UART drivers. Could you check if there is any software buffering inside your driver ? Like a 64~128 byte buffer on the RX. I should make it clearer somewhere in the docs that the UART driver should buffer for proper operation. By the way, now that I am looking at the stats you provided, I am almost sure there is no buffering either on the TX side, because I see that you have almost as many corrupted frames as valid ones. PS: Hope this is not too frustrating, sorry I cannot be of more efficient help, but those UART drivers can be some tricky beasts sometimes |
Hi sagonzal, I was wondering if you were able to solve your problemsm, if you need some help finding the buffered serial lib I indicated, I can give you a hand. I'm leaving this issue open for the moment |
Rémi, huge thanks for your support here. Let me tell you that I solve the issue and (as always are) was a complex combination of factors:
--> more on this as soon as I have some time to delve into this again. I strongly feel that a multi-byte buffer can help here. |
First Rémi, thank you for your hard work. I ported telemetry (plain C) to the K22FN512 (a cortex M4 cpu) platform on the K22F freedom board. And only recently I'm in the need of sending data from the host to the embedded.
I'm facing the issue that my variable is not updated even thou that I use update_telemetry(). I'm sure the issue is with:
The issue is that I don't have any "serial.readable();" And place the following in the driver:
Now my question is, amount has to be a single 8 bit char (amount = 1)or a whole message (amount = N)? That is the main difficult to porting since I do not know wow the real function "readable" works..
warmest regards
The text was updated successfully, but these errors were encountered: