BallAerospace / COSMOS

Ball Aerospace COSMOS
https://ballaerospace.github.io/cosmos-website/
Other
360 stars 129 forks source link

Router vs JSON API for non ruby command/telem processing #1042

Closed DanielKoohmarey closed 4 years ago

DanielKoohmarey commented 5 years ago

How would you recommend sending commands and receiving telemetry data from a c++ application? Would you create a router that the c++ application would connect as a tcp client to? Or would you use the COSMOS json api in conjunction with a custom protocol on the target to decode/encode the data as base64 (to support sending/receiving binary data with the json api). If there is another approach I am not understanding let me know. Thanks!

ghost commented 4 years ago

If you create a TCP client in your C++ application you can configure COSMOS as a TCP server that your application can connect to. You could also create a TCP server in your C++ application and configure COSMOS as a TCP client.

The other much more complex option would be to create a custom interface using something like FFI to directly call your C++ application.

ghost commented 4 years ago

An important detail is that you would do this with an INTERFACE and not ROUTER. Interfaces send commands and receive telemetry. ROUTERS are the opposite (receive commands and send telemetry).

Also, ideally the interface to your C++ app would be binary packets (not JSON or any text based interface). The natural use of COSMOS for commands and telemetry is binary packets that would line up with data structures in your C++ application.

DanielKoohmarey commented 4 years ago

Thanks for the additional information Ryan, however perhaps you can offer a little more insight. From the blog post on routers : "

As a reminder, an Interface provides the lowest level connection between COSMOS and a target (something you’re trying to get COSMOS to talk to). Thus a Router is also providing a low level connection between COSMOS and something. So what’s the difference? Normal Interfaces read the target and send data (telemetry) to COSMOS and send commands to the target. Routers do the exact opposite: they route telemetry out to clients connected to them and route commands sent to them back to a target. Thus they provide a conduit for other clients to communicate with a target.

" From my understanding after reading the post, an interface is used for a COSMOS connection to a target, while a Router would be used to connect something to a target. This makes it sound like I want a Router (configured as a TCP server) to connect my application to my target. Can you provide an explanation on why I want an interface vs a router if I am interested in having my c++ application exchange information with my target? I agree the ideal interface would support binary packets, this is the data I am interested in exchanging with the target. Thanks for your useful information so far.

ghost commented 4 years ago

I think I misread your first question. I was thinking that the C++ application was the target. It sounds like you want the C++ application to speak to a target through COSMOS.

In that case you can go through a ROUTER if you want to stream raw packets (for commands/telemetry), or you can use the JSON API to send commands textually, and query individual telemetry items (sending and receiving JSON text over HTTP). The JSON API may not be very fun to implement in C++. I would probably recommend just streaming the Raw packets with a ROUTER.

DanielKoohmarey commented 4 years ago

Thanks for the follow up Ryan, I will go with raw packets and a ROUTER. Do the raw packets need to have CCSDS headers added from the C++ application, or will COSMOS automatically add these?