OpenMarine

Full Version: Test my signal K python code?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello,

I have been struggling for few days to understand how everything works.

Good news is, I know a little bit how it is supposed to work now. Bad news is, I am stuck with some piece of code and I do not understand why. I hope you can help me on this.

This idea was simply to set "navigation.speedOverGround" with a short Python code and to check the result in localhost:3000/@signalk/instrumentpanel/

I used partly the code given here: https://github.com/olewsaa/Yacht-compute...lK-test.py

And the rest from SK-simulator.py


With the SK-simulator, the instrument panel is updated, with my code, nothing happens...

Any idea why??

Thanks a lot.

Lucas

Code:
#!/usr/bin/env python



import time, socket


# Initiate socket
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
# socket.AF_INET is  Internet
# socket.SOCK_DGRAM) is  UDP



while True:

   SignalK='{"updates": [{"$source": "OPsimulation","values":[ {"path":"navigation.speedOverGround","value":"1"+}]}]}'
   print(SignalK)

   sock.sendto(SignalK, ('127.0.0.1', 55557))
Code:
   SignalK='{"updates": [{"$source": "OPsimulation","values":[ {"path":"navigation.speedOverGround","value":"1"}]}]}\n'

The '+' shouldn't be there and I would also add a '\n' at the end.
(2018-02-21, 08:30 PM)e-sailing Wrote: [ -> ]
Code:
   SignalK='{"updates": [{"$source": "OPsimulation","values":[ {"path":"navigation.speedOverGround","value":"1"}]}]}\n'

The '+' shouldn't be there and I would also add a '\n' at the end.

Thank you, it works!!!!

Next step for me, make my Arduino mega change this value depending on an analog input value.


Lucas