OpenMarine

Full Version: Adding course info to Arduino serial
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
As I mentioned in another thread (link), I am working on controlling my PyPilot with a Raymarine ST7002 control head.
I've got the necessary SeaTalk communication ready and working on the Arduino (MEGA), but now I want to show the course info on the ST7002 screen.
I am looking in the python code as to where / how I should add the course information to the serial communication between the Pi and the Arduino, but have a hard time figuring that out.

Can someone point me in the right direction?

Regards,
Reinier
(2023-09-16, 10:26 PM)rbergevoet Wrote: [ -> ]As I mentioned in another thread (link), I am working on controlling my PyPilot with a Raymarine ST7002 control head.
I've got the necessary SeaTalk communication ready and working on the Arduino (MEGA), but now I want to show the course info on the ST7002 screen.
I am looking in the python code as to where / how I should add the course information to the serial communication between the Pi and the Arduino, but have a hard time figuring that out.

Can someone point me in the right direction?

Regards,
Reinier

Bump!

is there somebody who can point me in the right direction? As there is not much comments in the code, and my understanding of Python is not that good, I have a hard time figuring out how / where the serial communcation takes place.

Regards,
Reinier
you could write a simple service that communicates over serial to your device as well as connects to pypilot. this way you do not need to modify the core pypilot service itself. the pypilot hat and pypilot web clients are both examples of this.
(2023-10-10, 05:34 PM)seandepagnier Wrote: [ -> ]you could write a simple service that communicates over serial to your device as well as connects to pypilot.  this way you do not need to modify the core pypilot service itself.    the pypilot hat and pypilot web  clients are both examples of this.

Hi Sean,

thanks for your answer, I think this might indeed be the best solution.
Can you give me a clue as to in which file (maybe even the line number) I can best call my new script, so that it will be automatically called in the loop, so the course info in refreshed?

Regards,
Reinier
I am suggesting you write a separate script that runs its own process and service.
(2023-10-25, 01:53 AM)seandepagnier Wrote: [ -> ]I am suggesting you write a separate script that runs its own process and service.

Hi Sean,

I have been busy on getting the rest of the SeaTalk1 bus communication up-and-running, responsive and stable, and I nearly finished with that, so now I can resume working on this.
Can you give me some advice as to where in the code (which file) I can best call my new code, so that it will be called regularly to update the course? My Python reading is not that good, and I have a hard time following what the actual sequence in your Python code is, so some help would be great!
Since Pypilot already uses the serial pins on the Raspberry pi Zero for Tinyilot, I will have to use bitbanging GPIO for the serial, right?

Regards,
Reinier
Attached you will find a piece of python code that uses the pypilot_client library to communicate to pypilot. The script subscribes itself to a few parameter values in the pypilot operation data model, and will receive updates from pypilot because it has subscribed itself. The test payload is processThings() and it prints to the standard output the values of three of these parameters periodically. You would need to modify this script so it runs as a service in the background, it subscribes to the parameter values you need, and instead of printing those values to the prompt, pass those parameters to your seatalk scripts. So you won't need to tap into the arduino communication protocol.

This doodle was a bit of a finger exercise to condense the code required that I needed for another project. I think in it you will find all you need to achieve what you want. 

Good luck.
(2024-01-23, 10:07 PM)rbergevoet Wrote: [ -> ]
(2023-10-25, 01:53 AM)seandepagnier Wrote: [ -> ]I am suggesting you write a separate script that runs its own process and service.

Hi Sean,

I have been busy on getting the rest of the SeaTalk1 bus communication up-and-running, responsive and stable, and I nearly finished with that, so now I can resume working on this.
Can you give me some advice as to where in the code (which file) I can best call my new code, so that it will be called regularly to update the course? My Python reading is not that good, and I have a hard time following what the actual sequence in your Python code is, so some help would be great!
Since Pypilot already uses the serial pins on the Raspberry pi Zero for Tinyilot, I will have to use bitbanging GPIO for the serial, right?

Regards,
Reinier

Generally yes you would be limited to bitbanging.   You might want to use usb for this instead, or  a more recent raspberry pi which supports multiple hardware serial ports.

Your code can be a separate project from pypilot.  If it is a separate service it only needs to communicate to pypilot via sockets.
Oh, reading the other thread, do I understand now you want to integrate your seatalk software with motor.ino on the same arduino? That seems to me a very unholy plan, if I may say. An arduino is single thread, and motor.ino I believe relies heavily on timer based interrupt service routines, that are very finicky to debug and have to respond very fast. There are good bit-banging libraries (e.g., pigpio) available for raspberry (tinycore I don't know) for receiving seatalk, but sending is more difficult because you need to monitor the line for collisions while sending, as you might have already solved in your arduino sketch. I would say they best way forward for you is to add another arduino to your setup, and then you can use the extra uart on a more recent pi, as sean suggests, or the usb port.
that isnt what I read. I think he realizes the motor controller must use the only hardware serial port on the pi and to add an additional port would need bitbanging.
Pages: 1 2