Logo-amall

Native

Last active 6 months ago

80 replies

6 views

  • NI

    Native

  • NI

    @cooper , @Altay Kaktus I just finished the first step of the native development.
    Here is how to test it :
    1) Checkout this branch : https://github.com/Luos-io/luos_engine/tree/feat/native
    2) On Platformio, you can compile the example on example/projects/native/gate_wscom
    3) Run the program with ./example/projects/native/gate_wscom/.pio/build/native/program
    4) On your terminal you should see :
    Button serice running. Use the SPACE button to swap the button state. Starting WS listener on ws://localhost:9342/ws
    5) On another terminal, Install Pyluos with this particular branch : https://github.com/Luos-io/Pyluos/tree/feat/native
    6) Run the command : pyluos-shell --port localhost
    7) On your terminal you should see:
    ```Connected to "localhost".
    Sending detection signal.
    Waiting for routing table…
    Sending telemetry…
    Device setup.

    Hit Ctrl-D to exit this interpreter.

    Your luos device has been successfully mounted into a "device" object:
    ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
    ┃ ╭node 1 /!\ Not certified ┃
    ┃ │ Type Alias ID ┃
    ┃ ├> State button 2 ┃
    ┃ ├> Pipe Pipe 3 ┃
    ┃ ╰> Gate gate 1 ┃
    ╔>┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛

    In [1]: `` On the first terminal each time you tap onspacekey the button service state change, and you can see it on the second terminal (the python one) usingdevice.button.state`

  • NI

    Let me know if you try it and have any trouble.

  • CO

    I'll certainly give it a shot later when I have a chance!

  • KO

    Here is a quick implementation with the WebSocket API 🙂

  • NI

    Nice!

  • AL

    very cool!

  • AL

    Will start working on it too in a few minutes 😄

  • AL

    Nico, if you have any issues/tasks just add them to GitHub ill try to do some.

  • NI

    Great!

  • NI

    Today I will work on a document allowing everyone to understand the main goal of this native development and the different steps and constraints.

  • NI

    If you want @Altay Kaktus I will need to add Mdns service declaration on the WebSocket pipe. Is this something you could be interested on ?

  • AL

    i have no idea what that means but i will be happy to find out 😄

  • NI

    Don't worry, I will help you with any question you could have 😉

  • NI

    Just to gives you a little bit more context. For Now the example I just shared allow to run a binary with 3 services [Button, Gate, Pipe]. Pipe is the service dealing with the WebSocket and allowing other things to interact with those 3 services. ( For now we can't manage multiple binaries, this is the next step).
    For now this pipe Create a WS (websocket) server and relay all input and output of the websocket to the Gate service. This way Pyluos can send information for the Gate trough this WS pipe.

  • NI

    Pyluos is able to list the compatible interfaces available on the system. For now we are able to list available serial interface, but we should be able to make it also with this WS Pipe.

  • NI

    To do that we should add an Mdns(also known as Bonjour) support, allowing the WS Pipe to declare itself on the network to be "discoverable". For example Mdns is used by printers or Netflix to be discoverable on the network.

  • NI

    I'm creating an Issue about it, this way we can work on it together…

  • NI

    Here is the issue : https://github.com/Luos-io/luos_engine/issues/288

  • NI

    @Altay Kaktus @cooper here is a collection of issues explaining the native project. I will need your help to brainstorm on part 2.
    Please feel free to comment on the Issue : https://github.com/Luos-io/luos_engine/issues/292

  • AL

    @Nico 🤙 I answered on GitHub, check it out when you can. cya!

  • KO

    First Docker container running our "native" Gate !

  • NI

    Cool!

  • AL

    any chance you can send me your code?

  • KO

    @Altay Kaktus sure

  • KO

    I'll push the Dockerfile on the repo

  • KO

    i ping you once it's done 👍

  • AL

    which folder do I have to open in platformio? It says that its missing the *.ini file.

  • KO

    example/projects/native/gate_wscom

  • KO

    @Altay Kaktus you can checkout the branch, i pushed the Dockerfile in the example folder.
    docker build -f ./examples/projects/native/gate_wscom/.docker/Dockerfile .

  • CO

    Something I've found with the ESP family of boards at least, when using a websocket, the transmission time/receive time is noticably higher than via serial (like sub 5ms time to 15ms at times), depending how fast you are transmitting, it can cause 'drift' of the main thread/loop, even when reading/writing asynchronously to serial/websocket.

    I'd imagine the native hal isn't having those issues on the computer side, but if ever routed to a Luos node that's on an ESP that may be a concern for super fast data

  • AL

    The native branch is not build for embedded, and it is especially not build for high performance.

  • CO

    No no, but the websocket support I'm guessing is headed to support ESP boards, right?

  • CO

    Or other "wifi enabled" devices

  • AL

    Luos is not yet another web/microservices framework

  • CO

    It doesn't have to be to have web socket support?

  • CO

    You can do websocket to websocket from node to node vs to a server

  • AL

    i dont know if there are other plans to use websockets for that but native certainly is not made for that

  • CO

    I'm talking purely locally done

  • CO

    I was more on this part of the above links ->
    https://github.com/Luos-io/luos_engine/issues/291

    Where if you can pipe data to/from the native project via websocket, why not from other nodes in the future?
    Would be good for situations where running serial isn't ideal/possible

  • CO

    As if the native nodes can talk via websocket they also could talk to actual nodes too, perhaps more easily

  • NI

    You are right, this will be my next task…
    The native Pipe I just develop use WebSocket to be able to communicate with pyluos using it. @Salem just had a full working Luos on ESP a few minutes ago. So I will be able to make a Pipe service runing websocket to connect to pyluos.
    But as @Altay Kaktus mention we don't plan to work on Luosengine WS HAL communication yet. This is planed for Luosengine V3 early 2023. In V3 we will be able to deal with any kind of network. Then we will work on the support of multi-phy allowing Luos to deal with multiple network. This way an ESP running Luos_engine can deal with WS and serial network aggregating native and embedded services in a same routing table.

  • NI

    In the past we already had a WS pipe running on the ESP and we had some unknown crashes probably due to the number of messages sent trough websocket.
    I think we will have to pack some Pipe messages together to limit the number of message but increase the payload size…

  • CO

    Does Robus have a singular char string it outputs, and can it take in a single char string if not from serial?
    Or how does it format for output/input if not?

  • CO

    I ran into those - it looked like malformed packets it was attempting to send - I didn't have issues with that after tweaking the send speed via an "outputGate" so it queues changes to vars and only syncs out every x milliseconds

  • CO

    But if there is a method it writes out, giving a "callback" before it sends, and then having a var you can set from the callback on the Robus service to "handle" a packet could allow you to filter where you send it if you wanted - because you'd have that char string in the callback which could route elsewhere

  • NI

    Not sure to understand this question. Robus rely on Luos msg_t format. This messages includes a header allowing Luos to "route" messages to the good service(s).

  • CO

    Well the whole message string - I presume you parse a string in on receiving nodes, right?

  • NI

    Yes

  • CO

    So it goes to generate a message, header, payload and all

  • NI

    But you can have the payload you want in it

  • CO

    Is there a function where there's a singular buffer containing the output string recieved by the other device before send, is more what I'm asking

  • NI

    Yes we have a complete buffering management dealing with TX, RX, and filtered messages. You can find it in luosengine/network/robus/src/msgalloc.c. => https://github.com/Luos-io/luosengine/blob/main/network/robus/src/msgalloc.c
    This part of the code allocate in a predefined buffer messages and create "task" for each message with an associated pointer in the buffer allowing Luos functions and Hardware callbacks to use those messages.

  • NI

    We don't have any documentation about it but the code is well commented with drawing and stuff…

  • CO

    I think this is what I looking for, thanks!

  • NI

    You are welcome. Do not hesitate to ask me if you have any question about this code. This is not an easy piece of cake…

  • AL

    @Nico 🤙 you use Linux, right? 😄

  • AL

    because i cant get it to work on my windows pc, it needs GCC for that.

  • AL

    I will just switch to linux i think thats better anyway

  • NI

    I'm using mac

  • NI

    This have not been tested on windows but Pio should figure it out I guess. I didn't check if GitHub successfully compile it on windows. I will provide an update tomorrow.

  • NI

    On Github Action compilation failed due to a mistake on Arduino platform. I modify some script that created an error on the pipe compilation of other platform… I will push something to fix it today allowing use to check the native compilation on Linux, mac, and windows…

  • NI

    Here @Alan C. Assis

  • NI

    @Altay Kaktus you are right my native example compile on Mac and linux but not in windows as you can see at the bottom of this PR : https://github.com/Luos-io/luos_engine/pull/280

  • NI

    I think @JeromeAQuaMan already have this exact same issue with Luos_assert and solved it. He is on Holidays, I will ask him ASAP.

  • NI

    @Kordan I removed the serial protocol from the WebSocket (that was painfull). I remember that you made some code on your side to manage WebSocket from you Typescript tool. I think this will be easier for you.

  • NI

    I pushed it on Luos_engine/feat/native and pyluos/feat/native…

  • NI

    @everyone if someone is looking to contribute, there is this issue : https://github.com/Luos-io/luosengine/issues/288 to do on top of this branch : https://github.com/Luos-io/luosengine/tree/feat/native
    Let me know if anyone is interested.

  • KO

    Ok, i'll check it out the impacts on my side 👍

  • AL

    @Nico 🤙 did you fix the windows thingy?

  • NI

    Not yet, perhaps next week

  • NI

    Alternatively you can use the docker of @Kordan present on the example folder…

  • NI

    It should work I guess

  • NI

    @Altay Kaktus I wrote something about our discussion earlier this week.
    Can you check it out and let me know what you think about it?
    https://github.com/Luos-io/luos_engine/issues/291

  • NI

    @Kordan I think the Robus_emulator I mention in this Issue should be in a Docker (yes you are the Docker master here). It could be interesting to instantiate it automatically at node boot if no one is running on the network…

  • NI

    Also I think it's important to be able to configure the Robus_emulator used and not to always use the first one found on the network. If multiple developers are playing with it on the same LAN it could become an issue…

  • KO

    Ok i'd started to optimize the build of Docker images with multiple stages, i think the Robus_emulator could be part of a specific stage

  • NI

    Here is a quick view of how the native example work :

  • NI

    It's a little bit laggy today on my computer… But it's working fine.

  • NI

    @Altay Kaktus I ran some tests with @Salem regarding the windows compilation of the native example. It seems that windows doesn't support the __attribute__((weak)) symbol and fail during linking.
    I also had a look at the github actions of mongoose (because a lot of errors are comming from the lib) to see how they compile it on windows, and they seems to use Wine to compile it as a linux…

Last active 6 months ago

80 replies

6 views