I'm trying to conect my PX4Flow sensor to a raspberry pi. It seems that nearly everybody is using qgroundcontrol to access and control it. But as I'd like to integrate it into some bigger program, I'd like to control it with some self-written simple python code, if possible.
My aim is to:
access the camera (to measure the speed - later)
get gyrometer values
I don't need the ultra sonic sensor.
I found out that I can use MAVlink for the communication between the px4flow sensor and the raspberry pi. I cloned the git repository and followed the steps on https://github.com/mavlink/mavlink until the generation of header file (python -m mavgenerate). With that, I can generate a new python file. I don't know if this is correct, and I don't know what to do with that python file. No more file (header files) are copied or generated. How do I go on? How do I use the library? How do I even test the connection?
If I understand you correctly, you want to make a module to communicate with PX4Flow.
I have some experience in building a ground control station with ardupilot. I think the procedure is roughly the same:
Generate the proper mavlink library, what you have done by using mavgenerate. Read some guidance of mavlink communication procedure.
Read the source code in PX4Flow communication module https://github.com/PX4/Flow/blob/master/src/modules/flow/communication.c, which shows what kind of messages have been sent to client side (e.g. your communication module)
Start write the module code to communicate with PX4Flow. You may need to start with HEARTBEAT msg first to establish connections between your module and PX4Flow. Note that you can always receive HEARTBEAT messages from PX4Flow. You can start with decoding these ones.
Implement your other functionalities.
You can read sources code of QGourndControl during step 3 and step 4. Make sure to find the right module in its repo.
My communication module is built using JavaScript https://github.com/kvenux/nodegcs, if it helps.
Related
I am currently trying to create a React Native app that lets me connect to my OBD2 device and read data about my car from it. However, I am struggling to figure out the "reading data" step. I am able to connect to the device and see characteristics and services, but cannot read data from the characteristic. I've seen articles on running a set of commands to initialize the OBD, but I have no clue what I am doing wrong. These articles have said things such as:
Set the command protocol to AUTO by running AT SP 0. By running AT DP, you should get AUTO.
Convert the commands to base64.
Use the "\r" return carriage at the end.
Write to the characteristic and read the resulting value.
Could anyone with experience on this issue explain how I can use an ordinary BLE app to send a command (via write) and receive a command following (via read). I understand how to code the read/write, but not entirely sure how to implement this specifically with OBD2 devices.
Thank you for your time.
I have been trying to establish a network of ESP8266 (Specifically ESP-01). However, I am not able to find any documentation or anything related on how to actually communicate using HTTP GET and POST methods since I only need a temporary short time communication between multiple sending Nodes to one main Aggregator node.
I don't want to use any Arduino-related libraries as I'm working with STM32. However, I have seen some Arduino-based libraries related to this like ESPAsyncWebServer. But I am not able to find any AT-commands inside it and it's too complicated and intricate for me to understand.
I am basically making a custom library in short so how is communication using HTTP is done between 2 ESPs either using AT commands or any other way (I am going to be communicating to the ESP modules using a dedicated microcontroller through UART) or better if there's any other better way for implementing multiple to 1 connection on ESP. How can I establish this communication to basically send and receive numbers and characters.
I'm working on an ESP32 based project that will involve OTA flashes of the ESP.
I know that you can set up different partitions on an ESP32. I'm wondering if it's possible for my code on one partition to then execute code on another partition? (For my usage, I don't need data passed back and forth - just execution handed off from one partition to the other and than given back after execution)
Yes, assuming you don't have Flash encryption with different keys or other tricky copy protection mechanisms enabled. Partitions on Flash are a completely abstract concept for the developers' peace of mind. The CPU doesn't know and doesn't care - it will execute code from anywhere in Flash if told to jump to it.
The challenge here is that you need to convince the linker to find and call a method from an external, hard-coded address. And you need to make sure said method is actually there :) Since this is not a standard solution, you likely won't find a tutorial but have to know your linker really well :)
There's some useful stuff in the ESP IDF linker documentation and probably the GNU linker documentation, if I could find it :)
You will need some freeRTOS information.
I will not write any code here but I can give you some ideas on what you are trying to achieve.
Assume you have two tasks and a digital pin, which is pulled high by the setup() function. You define the task handler for each task. Now you want to change the current running program to some other program, you will check if the digital pin has been LOW for 5 seconds if that's the case , you can use the vTaskSuspend() function in the primary task by providing it the handler of your current task and suspend your current task. Be sure to resume your OTA task by vTaskResume() function before calling vTaskSuspend() . When you have completed the update, restart the esp32 by calling ESP.restart().
If you want to abort the OTA task just pull the same digital pin LOW and using the above method in your OTA task also, you can switch back to your primary task.
I will be asking a very subjective question, but it is important as I am looking to recover from failure to effectively use BlueZ programatically.
Basically I envision an IoT edge device that runs on a miniature computer (Ex: Raspberry pi or Intel Compute Stick). The device would then run AlpineLinux OS and interact with Cloud.
Since it is IoT environment, it is needless to mention the importance of Bluetooth BLE over ISM band. Hence the central importance of being able to customize and work with BlueZ.
I am looking to do several things with BlueZ BLE including but not limited to
Advertising
Pairing
Characteristic
Broadcast
Secure transport of data etc...
Since I will be needing full control over data, for data-processing and interacting with cloud (Edge AI or Data-science on Cloud) I am looking at three ways of using BlueZ:
Make DBus API calls to BlueZ Methods.
Modify BlueZ codebase and make install a custom bin.
(So that callback handlers can be registered and wealth of other bluez
methods can be invoked)
Invoke BlueZ using command line utils like hcitool/bluetoothctl inside a program using system() calls.
No 1 is where I have failed. It is exorbitant amount of effort to construct and export DBus objects and then to invoke BlueZ methods. Plus there is no guarantee that you will be able to take care of all BLE issues.
No 2 looks very promising and I want to fully explore how feasible it is to modify the BlueZ code to my needs.
No 3 is the least desirable option, but I want to have it as a fallback option nevertheless.
Given my problem statement, what is the most viable strategy forward? I am asking this aloud so that I do not make more missteps and cost myself time and efforts.
Your best strategy is to start with the second way (which you already found promising) as this is a viable solution and many developers go about this method in order to create their BlueZ programs. Here is what I would do:-
Write all the functionality of the system in some sort of flowchart or state machine. This helps you visualise your whole system and what needs to be done to reach your end goal.
Try to perform all the above functionality manually using bluetoothctl and btmgmt. This includes advertising, pairing, etc. I recommend steering away from legacy commands such as hcitool and hciconfig as these have been deprecated and have a very different code structure.
When stumbling upon something that is not the default in bluetoothctl/btmgmt or you want to tweak the functionality, update the source to do so.
Finally, once you manually get the system to perform the functionality that you need (it doesn't have to be all, it can just be a subset of the functions), you can move to automating the whole process. This involves modifying the source for bluetoothctl/btmgmt commands so that instead of manual intervention, everything would be event-driven.
This is a bonus, but if you can create automated tests using python or some other scripting language, then this would ensure that your system is robust and that previous functionality doesn't break when adding new ones.
By the end of this process, you'll have a much better understanding of the internals of bluetoothctl/btmgmt and D-BUS APIs that you might be able to completely detach your code from the original bluetoothctl/btmgmt or create the program from scratch.
You probably already know this, but when modifying the tools, this is the starting point for the source code:-
bluetoothctl - client/main.c
btmgmt - tools/btmgmt.c
For more references on using bluetoothctl commands and btmgmt, please see the links below:-
BlueZ D-Bus C or C++ Sample
Bluetoothctl set passkey
https://stackoverflow.com/a/51876272/2215147
Bluez Programming
Linux command line howto accept pairing for bluetooth device without pin
https://stackoverflow.com/a/52982329/2215147
Bluetooth Low Energy in C - using Bluez to create a GATT server
I hope this helps.
Is there a way for Flex / AIR to receive syslog notices from devices such as cisco switches etc? Does anyone know of any information I can read or sites to look at?
If you are talking about calling native methods, flex/air cannot do that. But there is an opensource AIR-Java bridge namely merapi that lets you connect your AIR app with java code. I guess java should be able to do what you are looking for.
AIR apps can read local files. In the case of receiving syslog notices from cisco switches or other devices, I used to set them up on the receiving machine to be added to the local syslog there to have everything in one place (we're not talking windows here :-)). Using mtail and grep I had a few consoles open that showed me what was coming in.
If you write an Actionscript parser to read your local syslog - using bytearray like described here - then it should be possible to read through the whole file and note the interesting bits (I haven't done this myself, so no guarantees!)
If it more a question of getting real time data from devices, I would look into snmp (but you will probably need to write additional stuff in php or python to query the devices for you).