OpenMarine
Test my signal K python code? - Printable Version

+- OpenMarine (https://forum.openmarine.net)
+-- Forum: OpenPlotter (https://forum.openmarine.net/forumdisplay.php?fid=1)
+--- Forum: How do I...? (https://forum.openmarine.net/forumdisplay.php?fid=3)
+--- Thread: Test my signal K python code? (/showthread.php?tid=1037)



Test my signal K python code? - Lucas_A - 2018-02-21

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-computer/blob/master/IoT/signalK-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))



RE: Test my signal K python code? - e-sailing - 2018-02-21

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.


RE: Test my signal K python code? - Lucas_A - 2018-02-22

(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