This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Test my signal K python code?
#1
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))
Reply
#2
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.
Reply
#3
(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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)