ttlappalainen / NMEA2000

NMEA2000 library for Arduino
532 stars 221 forks source link

Temporarly Disabled ForwardStream #111

Closed melucas closed 6 years ago

melucas commented 6 years ago

Hi,

Using the TemperatureMonitor example, I have the Forward of the N2k data setup tp send to the USB serial port as follows:

NMEA2000.SetForwardStream(&Serial); NMEA2000.SetForwardType(tNMEA2000::fwdt_Text);

I am adding a configuration menu to the serial port and need a way to pause/disable to ForwardStream. So far, the only way I can get the N2k output to stop and running the menu off the screen is to:

NMEA2000.EnableForward(false);

Before writing the menu and then:

NMEA2000.EnableForward(true);

After the menu is exited. This works, but it stops the flow of the data onto the N2k bus and my Raymarine MFD eventually resets the data display to --.

What is the correct way to pause the ForwardStream and then restart it?

Thank you, Michael

ttlappalainen commented 6 years ago

EnableForward is the right way, but I do not see why it would have any effect to the N2k bus traffic. There seem to be small configuration bug on forward bit definitions: static const int FwdModeBit_EnableForward They should be static const unsigned int FwdModeBit_EnableForward, but it should not have any effect.

Have you checked that data flow really stops and your loop continues running normally?

melucas commented 6 years ago

You are right. I my loops waiting for serial input I was not calling the N2K processing.

I've added that in and now it seems to be ignoring the NMEA2000.EnableForward(false); which I set before I display the menu. My MFD is getting the data, but I'm also seeing the N2K output on the serial console.

  1. Do I have to close the N2K connection and re open it after changing the EnableForward mode?
  2. How can I access the value of ForwardMode or FwdModeBit_EnableForward so I can check it in my loop processing? The are both protected variables and not accessible from my code.

Thank you, Michael

melucas commented 6 years ago

I figured out item 1 above. I was not calling NMEA2000.EnableForward(false); in the right order before displaying the menu.

Still looking for a suggestion on item 2 above.

ttlappalainen commented 6 years ago

Currently there is no way. In principle bool ForwardEnabled() const could be public.

melucas commented 6 years ago

Can you add that to your feature request list? I can work around that now using a variable in my code. Thanks, Michael