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
SeaTalk 1 to NMEA0183/2000 with Raspberry Pi
#33
(2020-09-08, 01:10 AM)Cari20 Wrote: https://github.com/dnegrotti/seatalk1_ou...lk1_out.py

You can import the flow directly into Nodered with this code:

Code:
[{"id":"c964b9cf.79b678","type":"signalk-app-event","z":"46419c75.a897b4","name":"NMEA0183 Out","event":"seatalkOut","x":110,"y":140,"wires":[["4633789b.f5aac8"]]},{"id":"4633789b.f5aac8","type":"python-function","z":"46419c75.a897b4","name":"Seatalk1 Out","func":"#!/usr/bin/env python\n#Sends seatalk1 datagrams to serial output\n#By Cari20 (2020) loosely based on Marco Bergman ST2000 RPi remote\n\nimport RPi.GPIO as GPIO\nimport serial\nimport binascii\n\nmsg2 = msg['payload']\nlst = msg2.split(\"*\")[0].split(\",\")\nlst.append(msg2.split(\"*\")[1])\n\nif lst[0]=='$STALK':\n  with serial.Serial('/dev/serial0', 4800, timeout=10, writeTimeout=0) as ser:\n      ser.parity = serial.PARITY_MARK\n      ser.write(binascii.unhexlify(lst[1]))\n      ser.parity = serial.PARITY_SPACE\n      for i in lst[2:-1]:\n        ser.write(binascii.unhexlify(i))\n      ser.close()\n\nreturn msg","outputs":1,"x":290,"y":140,"wires":[[]]}]


With this setup you can have bidirectional communication with the ST2000 and the autopilot app is fully functional, I have a very long ToDo list to keep adding functionality, as I mentioned before the ST40 emulation and also the OpenCPN waypoint navigation. This can be extended to any signalk event provided you translate it to a seatalk1 datagram and inject the message into the “Seatalk1 Out” node. 

If you (or any other member) need any further details feel free to enquire.

Cari20

Cari20, Great work and also for SignalK team.
When I imported and examine the node for phyton function while waiting my circuit parts for boat test, I see the some parsing for *$STALK but when I tested this on phyton at VSC at home, the output is not exactly what I expected. 
I'm not experienced on programming maybe  I'm missing something here?
Your support appreciated,
Thanks,Sancan
Test code and result is:
#Sends seatalk1 datagrams to serial output\
#By Cari20 (2020) loosely based on Marco Bergman ST2000 RPi remote\
msg2 = '*$STALK,30,00,0C'
print(msg2)
lst = msg2.split('*')[0].split(',')
print(lst)
lst.append(msg2.split('*')[1])
print(lst)
if lst[0]=='*$STALK':
   print('helloinif')
   for i in lst[2:-1]:
       print(lst[i])
       print('helloinloop')

Sancans-MacBook-Pro-2:~ sensesp$ /usr/bin/python /Users/sensesp/Documents/PythonScripts/gpioseatalk.py

*$STALK,30,00,0C

['']

['', '$STALK,30,00,0C']
Sancans-MacBook-Pro-2:~ sensesp$ 
Reply


Messages In This Thread
RE: SeaTalk 1 to NMEA0183/2000 with Raspberry Pi - by ckckrs - 2021-03-24, 05:27 PM

Forum Jump:


Users browsing this thread: 2 Guest(s)