mariokonrad / marnav

a library for MARitime NAVigation
Other
95 stars 48 forks source link

Read AND write from Devices #14

Closed arnegue closed 6 years ago

arnegue commented 6 years ago

I want to build up a multiplexing system, which writes AND receives messages from TCP (only write right now, but doesn't matter), NMEA-0183-Devices and one Seatalk-Bus.

I am able to receive seatalk messages (convert them to NMEA) and from NMEA-Devices.

The problem is, that i also want to WRITE to these buses. TCP is no problem.

But the examples (with default_nmea_reader or seatalk message_reader) only show message-receivers, but no writers. OR if there is a writer, it's is not a receiver.

Could you give an example how to do both?

mariokonrad commented 6 years ago

You are probably looking for this: examples/serial_to_tcp.cpp

arnegue commented 6 years ago

Thanks for your answer. I was talking about writing and reading on the serial bus with the default_nmea_reader or similar. Sorry for the confusion.

mariokonrad commented 6 years ago

Using boost::asio you can read and write to interfaces (TCP, serial). There are some examples using it, e.g. example/read_nmea_boostasio.cpp, examples/serial_to_tcp.cpp and example/simple_seatalk_nmea_converter.cpp.

arnegue commented 6 years ago

Okay, sorry i did not see the boost_asio_serial with writing too. I will have a look at it this evening.

A further question (maybe i should open up a issue more, but seems over the top). The serial read/write (especially read) is blocking. Is there a way for you to put in a timeout? I don't want to unnecessarily spawn a thread for every serial port i'm reading/writing on.

mariokonrad commented 6 years ago

Yes of course, asynchronous communication is possible. You could use select on a file descriptor or use boost.asio. I'm sure there are other options.

mariokonrad commented 6 years ago

The issue has obviously been dead, closing it.