Open usauerbrey opened 6 years ago
I made a fix so that it compiles not. I did not test the RTE code itself, since it is made by other.
The problem itself may come if you do not keep full error/warning reporting on on compiler. With PlatformIO one good thing is that you can set all warnings on and also treat all warnings as error. In this way there won't be any warnings on the code. And why warnings are critical - if you e.g. write a code: if ( Index=0 ) { doSomething; } , compiler gives you warning about obvious error, but if you allways get list 50 wanings, you probably do not read them all anyway and you will miss critical warnings.
Hi Timo
This does not really help. None of the 3 examples in NMEA0183 compile successfully. Bringing warnings to errors will not solve my problem. What ist RTE code?
Hi Timo
C:\Users\ISA\Documents\Arduino\libraries\NMEA0183-master\NMEA0183.cpp: In member function 'void tNMEA0183::kick()':
C:\Users\ISA\Documents\Arduino\libraries\NMEA0183-master\NMEA0183.cpp:141:50: error: 'class Stream' has no member named 'availableForWrite'
while ( MsgOutWritePos!=MsgOutReadPos && port->availableForWrite() > 0 ) {
^
C:\Users\ISA\Documents\Arduino\libraries\NMEA0183-master\NMEA0183.cpp: In member function 'bool tNMEA0183::SendBuf(const char*)':
C:\Users\ISA\Documents\Arduino\libraries\NMEA0183-master\NMEA0183.cpp:156:18: error: 'class Stream' has no member named 'availableForWrite'
for (; port->availableForWrite() > 0 && buf[iBuf]!=0; iBuf++ ) {
^
exit status 1 Error compiling for board Arduino Due (Programming Port).
For some reason they have not defined that for DUE. You can add availableForWrite manually (version depends of your library version):
to file: "C:\Users\
virtual size_t write(uint8_t) = 0;
virtual int availableForWrite(void) = 0;
size_t write(const char *str) {
and to file: "C:\Users\lappalai\AppData\Local\Arduino15\packages\arduino\hardware\sam\1.6.11\cores\arduino\HardwareSerial.h"
virtual operator bool() = 0;
virtual int availableForWrite(void)=0;
Hi Timo Thanks for quick replay. Now is wokong .
I have another question. My curent setup is: NMEA0183:-GPS -Compas -openCpn (-Autopilot in future) NMEA2000:-wind sensor - B&G Triton displays - transducer
Is It possible tu set up arduino to send data in this way?: n2k>0183 -wind data from sensor 0183>n2k -gps -compas -waypoints -laylines -true and aperent wind...
Thanks again Martin
Yes it it. You just need to write handlers in bot direction. There are examples for both, which you need to combine and make your own handling. Since you are using DUE and it has build in two USB, you could do it like this: NMEA0183 -> DUE Serial 1 DUE Serial (Default USB) N2k -> Computer ( just use library default forwarding method) DUE USBSerial NMEA0183 format -> Computer openCPN
So take NMEA 0183 traffic to DUE and forward it to USBSerial. Also parse data and forward it to N2k bus. parse N2k bus data and forward it as NMEA0183 format to USBSerial. Then you have data in computer in both N2k and NMEA0183 format. If you use PC, take a look to OpenSkipper, which I use as WebServer for my data. If you use RPi, check SignalK project how to build WebServer for N2k data.
Hi Timo I tried but this is to much fo my knowledge at this time, is there any way you can help me with this? Thanks Martin
Do you mean code for DUE? I'll could combine something for start. The waypoints is complex. Can you run NMEA0183 with 38400 bps on reception end? Otherwise there is no room for all messages.
Hi Timo I would really appreciate your help Yes i mean for DUE card. My NEMA183 is curently runing on 57600 bps. I can change if it is necessary. Thanks Martin
Hi Timo Any progres with NMEA0183<>NMEA2000 handlers for Arduino DUE ? I am waitig for your help. Thanks Martin
Sorry I have been busy. I'll try to find time.
There is now first iteration of converter. Connect: GPS -Compas -> Due Serial3 (Rx3). Due second USB (USBSerial) -> OpenCpn On USB there is all data in Actisense format
Great, you are the best... thanks. I will test on monday and I will let know.
I updated the example with some improvements.
Hi I made a test with previus version of example(not updated) and it works great. The only thing I noticed is when I shoot down opencpn the GPS data(nmea0183) is not transmited anymore to nmea2000 (I dont have COG,SPD,POS data on triton displays). When I restart opencpn all woks fine. I will report if is the same with updated one.
The new version does not make difference, since it just has some cosmetic changes. If I remember right this is the problem with DUE port. I'll try to look it.
I updated the example, but it does not solve the problem. SerialUSB will block regardless using current method or just print, when you close the port. Serial does not do that, so as I added to comment:
If you do not need NMEA2000 messages forwarded to PC, define Serial for NMEA0183_Out_Stream and comment line:
#define N2kForward_Stream Serial
I do not have time to go deeper to the SerialUSB problem.
Hello, I am porting the NMEA library on an Arduino Mega. Got several issues linked to time.h vs Time.h and some missing methods, but I have made some changes to be able to compile. However, when starting the Arduino it hangs on the first Serial.print. No way to have a single printout even with no NMEA class or function called before. If I comment out all NMEA includes, then the printout works normally.
I suspect something incompatible in low level includes, but hard to catch. Any hint ?
Do you also have NMEA2000 library included? Mega has so little RAM and it can just run NMEA2000 library, but maybe not together with NMEA0183 library. Other problem may be that to simplify things I have used sprintf, which also eats memory.
I prefer to use Teensy 3.2 boards or better. They are more powerfull and has more memory.
Hello,
No I have just the NMEA one. Here is the code that hung
`#include
/ tNMEA0183Msg NMEA0183Msg; tNMEA0183 NMEA0183; /
void setup() {
Serial.begin(9600); Serial.print("Print NMEA test start...\n"); Serial.flush(); delay(1000); // NMEA0183.Begin(&Serial3,3, 9600); }`
If I comment the include statements from the NMEA library then it works, meaning that the Serial.print is executed properly.
I still think problem it is related to low memory and e.g. sprintf. I got rather beginning frustrated with Mega due to its low memory.
I agree that 8K of memory is indeed an issue, but in this particular case, I suspect rather a library conflict at very low level, because even Serial is not working while no NMEA code has been yet executed. I will investigate a bit or giveup if no obvious solution found. Moving to a larger CPU is an option or working something more frugal (simple multiplexing) inside the Arduino.
Thank you anyway
Have you checked Teensy boards? I have used them a lot and in boat I have e.g. temperature monitor for NAME 2000 network using 1-wire sensors. By compiling Teensy 3.2 to 24 MHz it draws only 13 mA from 12V.
I've been trying to compile a slightly modified version of the NMEA0183ToN2k example for a Teensy 3.2, but I'm also getting Time.h library errors.
from src/NMEA0183Handlers.cpp:19:
lib/NMEA0183/NMEA0183Msg.h:51:9: error: 'tm' does not name a type
typedef tm tmElements_t;
^
And then a list of errors to all the calls to functions within Time.h. If I build the same code for the ESP32, I'm not getting any errors. Is the code that big that it won't fit on a Teensy as well?
EDIT: I'd been using PlatformIO and decided to try it in the official Arduino/teensyduino IDE...which worked just fine. Must be an issue with PlatformIO.
This is an issue with time library. There has been different time.h libraries and some has missed some definitions. That example is old and should be updated. I try to find time for best solution.
This is maybe the same issue that I have on Arduino with different symptoms. To be able to compile I had to tweak the code for using Time.h. I will double check the details and post here. But this can explain why the system hung due to a type mismatch somewhere.
Hi. I get the follwing error when tryin to compile for the teensy 3.2
Arduino: 1.8.7 (Linux), TD: 1.44, Board: "Teensy 3.2 / 3.1, Serial, 96 MHz (overclock), Faster, US English"
Build options changed, rebuilding all
In file included from /home/sebastian/CloudStation/apps/arduino-1.8.7/libraries/NMEA0183/NMEA0183.h:30:0,
from /home/sebastian/CloudStation/apps/arduino-1.8.7/libraries/NMEA0183/Examples/NMEA0183ToN2k/NMEA0183ToN2k.ino:24:
/home/sebastian/CloudStation/apps/arduino-1.8.7/libraries/NMEA0183/NMEA0183Msg.h:51:12: error: conflicting declaration 'typedef struct tm tmElements_t'
typedef tm tmElements_t;
^
In file included from /home/sebastian/CloudStation/apps/arduino-1.8.7/hardware/teensy/avr/libraries/Time/Time.h:1:0,
from /home/sebastian/CloudStation/apps/arduino-1.8.7/libraries/NMEA0183/Examples/NMEA0183ToN2k/NMEA0183ToN2k.ino:20:
/home/sebastian/CloudStation/apps/arduino-1.8.7/hardware/teensy/avr/libraries/Time/TimeLib.h:53:4: note: previous declaration as 'typedef struct tmElements_t tmElements_t'
} tmElements_t, TimeElements, *tmElementsPtr_t;
^
In file included from /home/sebastian/CloudStation/apps/arduino-1.8.7/hardware/teensy/avr/libraries/Time/Time.h:1:0,
from /home/sebastian/CloudStation/apps/arduino-1.8.7/libraries/NMEA0183/Examples/NMEA0183ToN2k/NMEA0183ToN2k.ino:20:
/home/sebastian/CloudStation/apps/arduino-1.8.7/hardware/teensy/avr/libraries/Time/TimeLib.h:94:33: error: expected identifier before '(' token
#define daysToTime_t ((D)) ( (D) * SECS_PER_DAY) // fixed on Jul 22 2011
^
/home/sebastian/CloudStation/apps/arduino-1.8.7/libraries/NMEA0183/NMEA0183Msg.h:86:19: note: in expansion of macro 'daysToTime_t'
static time_t daysToTime_t(unsigned long val);
^
/home/sebastian/CloudStation/apps/arduino-1.8.7/hardware/teensy/avr/libraries/Time/TimeLib.h:94:37: error: expected ',' or '...' before '*' token
#define daysToTime_t ((D)) ( (D) * SECS_PER_DAY) // fixed on Jul 22 2011
^
/home/sebastian/CloudStation/apps/arduino-1.8.7/libraries/NMEA0183/NMEA0183Msg.h:86:19: note: in expansion of macro 'daysToTime_t'
static time_t daysToTime_t(unsigned long val);
^
In file included from /home/sebastian/CloudStation/apps/arduino-1.8.7/libraries/NMEA0183/NMEA0183.h:30:0,
from /home/sebastian/CloudStation/apps/arduino-1.8.7/libraries/NMEA0183/Examples/NMEA0183ToN2k/NMEA0183ToN2k.ino:24:
/home/sebastian/CloudStation/apps/arduino-1.8.7/libraries/NMEA0183/NMEA0183Msg.h:86:49: error: 'D' declared as function returning a function
static time_t daysToTime_t(unsigned long val);
^
/home/sebastian/CloudStation/apps/arduino-1.8.7/libraries/NMEA0183/NMEA0183Msg.h: In static member function 'static void tNMEA0183Msg::SetYear(tmElements_t&, int)':
/home/sebastian/CloudStation/apps/arduino-1.8.7/libraries/NMEA0183/NMEA0183Msg.h:74:84: error: 'struct tmElements_t' has no member named 'tm_year'
static inline void SetYear(tmElements_t &TimeElements, int val) { TimeElements.tm_year=val-1900; } //
^
/home/sebastian/CloudStation/apps/arduino-1.8.7/libraries/NMEA0183/NMEA0183Msg.h: In static member function 'static void tNMEA0183Msg::SetMonth(tmElements_t&, int)':
/home/sebastian/CloudStation/apps/arduino-1.8.7/libraries/NMEA0183/NMEA0183Msg.h:75:85: error: 'struct tmElements_t' has no member named 'tm_mon'
static inline void SetMonth(tmElements_t &TimeElements, int val) { TimeElements.tm_mon=val>0?val-1:val; }
^
/home/sebastian/CloudStation/apps/arduino-1.8.7/libraries/NMEA0183/NMEA0183Msg.h: In static member function 'static void tNMEA0183Msg::SetDay(tmElements_t&, int)':
/home/sebastian/CloudStation/apps/arduino-1.8.7/libraries/NMEA0183/NMEA0183Msg.h:76:83: error: 'struct tmElements_t' has no member named 'tm_mday'
static inline void SetDay(tmElements_t &TimeElements, int val) { TimeElements.tm_mday=val; }
^
/home/sebastian/CloudStation/apps/arduino-1.8.7/libraries/NMEA0183/NMEA0183Msg.h: In static member function 'static void tNMEA0183Msg::SetHour(tmElements_t&, int)':
/home/sebastian/CloudStation/apps/arduino-1.8.7/libraries/NMEA0183/NMEA0183Msg.h:77:84: error: 'struct tmElements_t' has no member named 'tm_hour'
static inline void SetHour(tmElements_t &TimeElements, int val) { TimeElements.tm_hour=val; }
^
/home/sebastian/CloudStation/apps/arduino-1.8.7/libraries/NMEA0183/NMEA0183Msg.h: In static member function 'static void tNMEA0183Msg::SetMin(tmElements_t&, int)':
/home/sebastian/CloudStation/apps/arduino-1.8.7/libraries/NMEA0183/NMEA0183Msg.h:78:83: error: 'struct tmElements_t' has no member named 'tm_min'
static inline void SetMin(tmElements_t &TimeElements, int val) { TimeElements.tm_min=val; }
^
/home/sebastian/CloudStation/apps/arduino-1.8.7/libraries/NMEA0183/NMEA0183Msg.h: In static member function 'static void tNMEA0183Msg::SetSec(tmElements_t&, int)':
/home/sebastian/CloudStation/apps/arduino-1.8.7/libraries/NMEA0183/NMEA0183Msg.h:79:83: error: 'struct tmElements_t' has no member named 'tm_sec'
static inline void SetSec(tmElements_t &TimeElements, int val) { TimeElements.tm_sec=val; }
^
/home/sebastian/CloudStation/apps/arduino-1.8.7/libraries/NMEA0183/NMEA0183Msg.h: In static member function 'static int tNMEA0183Msg::GetYear(const tmElements_t&)':
/home/sebastian/CloudStation/apps/arduino-1.8.7/libraries/NMEA0183/NMEA0183Msg.h:80:87: error: 'const struct tmElements_t' has no member named 'tm_year'
static inline int GetYear(const tmElements_t &TimeElements) { return TimeElements.tm_year+1900; }
^
/home/sebastian/CloudStation/apps/arduino-1.8.7/libraries/NMEA0183/NMEA0183Msg.h: In static member function 'static int tNMEA0183Msg::GetMonth(const tmElements_t&)':
/home/sebastian/CloudStation/apps/arduino-1.8.7/libraries/NMEA0183/NMEA0183Msg.h:81:88: error: 'const struct tmElements_t' has no member named 'tm_mon'
static inline int GetMonth(const tmElements_t &TimeElements) { return TimeElements.tm_mon+1; }
^
/home/sebastian/CloudStation/apps/arduino-1.8.7/libraries/NMEA0183/NMEA0183Msg.h: In static member function 'static int tNMEA0183Msg::GetDay(const tmElements_t&)':
/home/sebastian/CloudStation/apps/arduino-1.8.7/libraries/NMEA0183/NMEA0183Msg.h:82:86: error: 'const struct tmElements_t' has no member named 'tm_mday'
static inline int GetDay(const tmElements_t &TimeElements) { return TimeElements.tm_mday; }
^
/home/sebastian/CloudStation/apps/arduino-1.8.7/libraries/NMEA0183/NMEA0183Msg.h: In static member function 'static time_t tNMEA0183Msg::makeTime(tmElements_t&)':
/home/sebastian/CloudStation/apps/arduino-1.8.7/libraries/NMEA0183/NMEA0183Msg.h:83:92: error: cannot convert 'tmElements_t*' to 'tm*' for argument '1' to 'time_t mktime(tm*)'
static inline time_t makeTime(tmElements_t &TimeElements) { return mktime(&TimeElements); }
^
/home/sebastian/CloudStation/apps/arduino-1.8.7/libraries/NMEA0183/NMEA0183Msg.h: In static member function 'static void tNMEA0183Msg::breakTime(time_t, tmElements_t&)':
/home/sebastian/CloudStation/apps/arduino-1.8.7/libraries/NMEA0183/NMEA0183Msg.h:84:89: error: no match for 'operator=' (operand types are 'tmElements_t' and 'tm')
static inline void breakTime(time_t time, tmElements_t &TimeElements) { TimeElements=*localtime(&time); }
^
In file included from /home/sebastian/CloudStation/apps/arduino-1.8.7/hardware/teensy/avr/libraries/Time/Time.h:1:0,
from /home/sebastian/CloudStation/apps/arduino-1.8.7/libraries/NMEA0183/Examples/NMEA0183ToN2k/NMEA0183ToN2k.ino:20:
/home/sebastian/CloudStation/apps/arduino-1.8.7/hardware/teensy/avr/libraries/Time/TimeLib.h:53:4: note: candidate: constexpr tmElements_t& tmElements_t::operator=(const tmElements_t&)
} tmElements_t, TimeElements, *tmElementsPtr_t;
^
/home/sebastian/CloudStation/apps/arduino-1.8.7/hardware/teensy/avr/libraries/Time/TimeLib.h:53:4: note: no known conversion for argument 1 from 'tm' to 'const tmElements_t&'
/home/sebastian/CloudStation/apps/arduino-1.8.7/hardware/teensy/avr/libraries/Time/TimeLib.h:53:4: note: candidate: constexpr tmElements_t& tmElements_t::operator=(tmElements_t&&)
/home/sebastian/CloudStation/apps/arduino-1.8.7/hardware/teensy/avr/libraries/Time/TimeLib.h:53:4: note: no known conversion for argument 1 from 'tm' to 'tmElements_t&&'
In file included from /home/sebastian/CloudStation/apps/arduino-1.8.7/hardware/teensy/avr/libraries/Time/Time.h:1:0,
from /tmp/arduino_build_225016/sketch/NMEA0183Handlers.h:19,
from /tmp/arduino_build_225016/sketch/NMEA0183Handlers.cpp:20:
/home/sebastian/CloudStation/apps/arduino-1.8.7/hardware/teensy/avr/libraries/Time/TimeLib.h:53:4: error: conflicting declaration 'typedef struct tmElements_t tmElements_t'
} tmElements_t, TimeElements, *tmElementsPtr_t;
^
In file included from /home/sebastian/CloudStation/apps/arduino-1.8.7/libraries/NMEA0183/NMEA0183Messages.h:29:0,
from /tmp/arduino_build_225016/sketch/NMEA0183Handlers.cpp:19:
/home/sebastian/CloudStation/apps/arduino-1.8.7/libraries/NMEA0183/NMEA0183Msg.h:51:12: note: previous declaration as 'typedef struct tm tmElements_t'
typedef tm tmElements_t;
^
Error compiling for board Teensy 3.2 / 3.1.
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
I installed arduino+teensyduino, example and necessary libraries to clean PC. It compiled without problems. I do not have linix available, so I can not test the problem. One reason may be that on include there is
For some reason they have not defined that for DUE. You can add availableForWrite manually (version depends of your library version): to file: "C:\Users
\AppData\Local\Arduino15\packages\arduino\hardware\sam\1.6.11\cores\arduino\Print.h" virtual size_t write(uint8_t) = 0; virtual int availableForWrite(void) = 0; size_t write(const char *str) {
and to file: "C:\Users\lappalai\AppData\Local\Arduino15\packages\arduino\hardware\sam\1.6.11\cores\arduino\HardwareSerial.h"
virtual operator bool() = 0; virtual int availableForWrite(void)=0;
Hi Timo,
This solution appear to work fine with this library/project. However, after adding these lines, my others Arduino skeches stop compiling with different error message.
Is this problem specific to Arduino Due ? Will I have the same problem with Arduino Mega ?
Have you planned or is it possible to correct this issue directly in the NMEA0183 library ?
And finally, thank you for your GREAT JOB !!!
Hugo
I expect that errors must be caused, if you use on other skecthes classes inherited from print class and they does not have availableForWrite defined. virtual int availableForWrite(void)=0;
defines abstract method, which have to be defined in inherited classes. One way would be to add e.g. virtual int availableForWrite(void) { return 50;}
to inherited classes code.
Still I do not understand, why they have not defined that for DUE and on its inherited classes.
It is problematic to fix on NMEA0183 library. With define I could make it so that it does not check it for DUE, but then it would mean that your code would block for writing data and your loop would stop until everything would have been written.
I have totally skipped DUE and changed to Teensy, since Teensy has more memory and draws less current.
Timo,
Thank you for your answer.
Last question: Which version of Teensy do you use for that project ?
Again, thanks for that great job !
Hugo
That depends of project. Very big or projects requiring SDCard Teensy 3.6. Teensy 3.2 can do really lot. Also if you compile Teensy 3.2 to 24 MHz it can still handle NMEA 2000, but it draws only 13 mA on 12V with good DC-DC converter.
Hi Timo
Maybe a silly problem, but I am unable to compile die examples of the NMEA0183 library:
C:\Users\Uwe\Documents\Arduino\libraries\NMEA0183/NMEA0183Messages.h: In member function 'char* tRTE::operator const':
C:\Users\Uwe\Documents\Arduino\libraries\NMEA0183/NMEA0183Messages.h:50:11: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if (i > nrOfwp || i < 0) {
C:\Users\Uwe\Documents\Arduino\libraries\NMEA0183/NMEA0183Messages.h:53:11: error: invalid conversion from 'const char' to 'char' [-fpermissive]
C:\Users\Uwe\Documents\Arduino\libraries\NMEA0183/NMEA0183Messages.h:58:21: error: invalid conversion from 'const char' to 'char' [-fpermissive]
Any idea? best Regards Uwe
BTW, the example in the NMEA2000 lib work fine