-
Notifications
You must be signed in to change notification settings - Fork 155
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
[WIP] Protocol JJRC345 #853
base: master
Are you sure you want to change the base?
Conversation
Just curious, what is blocking this PR? I have a multiprotocol module and this particular drone, could I help with development here? |
That's because this protocol isn't complete, we need someone with a stock TX to make some more XN297 dumps (with the tool built-in DeviationTX), please read the thread that's linked in the first comment then post in the forums if you're willing to help. |
If you do not have a DeviationTX radio but OpenTX+MultiModule you can make a custom build of the MultiModule to enable the XN297 dump protocol. |
Nice. So I flashed the XN297Dump firmware to the MultiModule and following the suggestions in the post seem to have sniffed out the following:
Let me know if I can offer more help. As noted, I don't have a DeviationTX transmitter, but I suspect it should be easy to try a proof of concept implementation on the multiprotocol module, right (mine is the STM-based Jumper4in1). |
Can you try to implement it in MPM ? |
My XN297Dump is working quite well ;-) It finds the freq being used, order and timing on its own :D |
I don't know either, the guy who started to capture the packets stopped responding on the forums :( |
My code was only for testing, packet period is set with a protocol option |
I'm currently adding the proto to Multi. |
@konstantint I'm wondering about this:
For me it doesn't make sense... |
I'd just map it to 00-80-FF |
That's what I meant, the signal is 70 on the far left and F0 on the far right, which looks unintuitive to me, I'd expect 00 at the far left. However, as you move the stick to the left, the value first changes from 80 to 01 and then starts increasing. |
@pascallanger, indeed, the auto-search functionality of your XN297Dump is amazing! |
@konstantint How do you do flips on this quad? It's not in your assessment. |
Strangely, nothing seemed to change when I clicked the flip shoulder button. I now think that maybe it only works at some throttle value or only on some of the four channels. I'll try to look into it again soon. |
OK, I found the flip. Apparently, the signal for the flip is setting the corresponding channel to FF or 7F momentarily - the flip button on the shoulder itself is not transmitted. |
@konstantint I've updated the MPM master on GitHub with the JJRC345 protocol. |
Our posts have crossed... |
To make a flip you first click the shoulder button, the TX starts beeping, after which you move the AIL/ELE stick in the desired direction, which makes the transmitter send the maximum value for that channel in that direction. |
Out of curiosity I decided to make sure the chosen channels are correct and did some extra measurements. The auto-scan functionality seems to reliably reproduce the result like the following:
However, if I manually tune in to some of these channels, things look a bit different. So I fixed the stock TX sticks to a nonzero position with a rubber band and tuned for each of the channels between 65 and 79 for 30 seconds, counting the number of packets received, which of those were bad and good, and looking at the "Channel" byte of the good channels. The results look like that: |
I'll try compiling the MPM now, haven't done that before. |
Ok let me know if you run into troubles but it should be straight forward... |
Right, I tried your protocol code. It kind-of-works in the sense that it sometimes manages to bind and the binding sometimes manages to persist long enough (~5-10 seconds or so) to try controlling the drone. The controls seem to be correct (also, the flips happen when the sticks are moved to the extreme positions). Unfortunately, the connection is very flaky and is often lost (the several cases where it binds, senses some throttle and flies away immediately losing the binding gives a whole new meaning to the term "Bind and Fly" for me). I tried removing the FORCE_ID definition and it kind-of-works as well, but it feels worse (not sure if I'm just imagining things). Would tuning the packet period help? I tried some values in vain. It would be nice if this could be done via the option parameter, because reflashing every new value is annoying (and I'm not familiar enough with the code to find how to do this quickly). Having read the code the whole frequency hopping thing makes sense to me now, however I did a couple of attempts to listen in to the stock TX and noticed that it seems to mostly hop between 0x41 and 0x47 (i.e. all the packets on channel 0x41 point to 0x47 and vice versa). There are very rare packets on the two other channels and those somehow seem to also only point only between them. Another unclear thing is with the binding channel. I'm pretty sure only channel 2 is used to send the binding packets - nothing is sent on channel 5 neither during nor after binding. Your code sets it to 5 (apparently because the number is mentioned in the packet) and it works fine none the less. I'm not sure whether this could be a problem. |
I've just pushed a new code on master with the debug outputs for the rf_ch+packet. It matches what you've posted above... Flip should not happen anymore when you go to full extreme, instead you need to set CH5 while moving the stick in the direction you want the flip to happen. |
Looking at the pictures on the Deviation forum the current checksum calculation cannot be applied to all packets. So I really need a full dump with loads of movement on the sticks and buttons to see how the checksum calculation changes. |
If you think bind is difficult due to the channel 5 being used, change this line: |
Here is the log of the auto-scan routine. You are right - the checksum computation you suggested seems to only be correct about half the time, and this may be the reason for the dropouts. I also think it is a bit strange that not all of the four channels are used equally, which means the stock TX is not really doing a uniform hopping at all. I'll record small sessions for each of the four channels to make sure. |
I tried changing the But it does not affect things much - the quad eventually binds for either channel (perhaps trying at a longer distance would show the difference). |
Here is the log, obtained by playing with the sticks and buttons while tuning in to the four presumably main channels ~ 1-1.5 minutes each. Things to note:
Maybe I'm misunderstanding how the packet capture works in XN297Dump, but if it simply reports everything that flows through the air, this does not look like a cyclic frequency hopping. |
Another observation: the correct checksum can be computed by adding the first 13 packet bytes except the fourth one plus two:
The meaning of the fourth byte still evades me, though. It can have four different values: |
Another curiosity. The bind seems to persist as long as I am moving the stick around actively. As soon as I stop doing it, the signal latency quickly (within milliseconds) increases, the quad stops responding, and, soon after (still within a second), starts blinking indicating a lost transmitter. |
Good finding. I've just posted another version with the corrected checksum. I'm guessing you might have already tried with it but if not please give it a go. |
I'm thinking this is because by moving the sticks he is receiving something (check , sum...) which is pleasing him so it stays locked to your signal. As soon as he has incorrect packets they start to deviate and it gives up. |
I've looked at your file(s) but they are a little too wild to draw any conclusion. |
Yes, the dumps were made by random stick movements hoping to find the checksum rule and are not helpful for figuring out packet[3]. More observations: the bind is not lost if I keep the aileron & elevator signal values above 0. Given that packet[3] does seem to change from A to E or 6 when the Ail/Ele stick is in the lower left region, I have a strong hunch that figuring out the mystery of packet[3] is the only thing left now. I'll eyeball the logs now a bit more. Oh, btw, I can't seem to make use of the serial debug in the version I'm compiling myself - I'm uncommenting DEBUG_SERIAL and commenting out a couple of protocols to have the binary fit, but I don't see anything on the terminal. |
OK, I think I know the rule now. The value of Another way to describe this would be as follows:
(Apparently, there's an imaginary byte I'll try it out now. |
Woohoo, it works! 🎉 So, to summarize, that's how you compute the checksum bytes:
The headless and RTH switches work fine. The flip switch is unusable (basically, as soon as I turn it on, the quad starts flipping in random directions like crazy). I think the correct way to implement it would be something like this:
As a last thing, I'll see whether binding on channel 2 rather than 5 works better at a distance now. |
Two last bits of information:
|
An unrelated question. OpenTX seems to limit the max protocol number to 63 (so I had to remap this protocol to something else). Do you know whether this has been improved in the latest OpenTX releases (I'd prefer not to upgrade without a good reason). |
Yes, OpenTX 2.3 supports more than 64 protocols, you should upgrade, a lot of work has been done in 2.3 for MPM integration. |
Awesome! You made it! I've pushed a new code version on GitHub. Can you test it and see if we could call it final? For serial debug, you need to do it from Arduino. Under "Board: Multi 4-in-1", you have Debug option. For OpenTX, you should try the latest nightly 2.3.8, the release 2.3.8 is only a couple of days away. With this version you don't need custom anymore, the module tells the radio what to display like protocol name, sub protocol, option field... Also the protocols are ordered alphabetically and many more. Pascal |
I think you forgot to push the code to master. |
And before you commit your last version, let's add one extra change. Namely, replace the maximal values for the rud/ail/ele with I was hoping the speed could be increased further by setting the trim signal, but the effect is so miniscule it is not worth the hassle. |
Can you check the latest Master? It's there now. Hopefully this is the last commit after that I will do a release. |
A largely symbolic contribution to record participation in protocol development. See: DeviationTX/deviation#853
Yes, all works fine. I do think that the flip logic should be changed to be less sensitive. With the current parameters it starts flipping way too early and stick space in the center is needed to be able to keep the quadcopter under control before doing the flip. I sent a symbolic PR for that. |
A largely symbolic contribution to record participation in protocol development. See: DeviationTX/deviation#853
Protocol for JJRC 345 mini quadcopter
Reverse engineered thanks to the built-in Deviation XN297 dumper !
https://www.deviationtx.com/forum/protocol-development/8329-jjrc345-drones-as-gift-in-return-for-protocol