ttlappalainen / NMEA2000

NMEA2000 library for Arduino
527 stars 220 forks source link

Compiling on Teensy4.0 #152

Open slick-wille opened 4 years ago

slick-wille commented 4 years ago

I have been using the Teensy 3.6 with this library and have had no problems. Now I decided to upgrade to the Teensy 4.0, but I am having an error when compiling with the new one. When compiling on the 4.0, I get this error.

... src/NMEA2000_Can.h:122:26: fatal error: NMEA2000_mcp.h: No such file or directory compilation terminated.

Why would the same code not compile on a different board? Thanks.

ttlappalainen commented 4 years ago

There is no support for Teensy 4 yet.

ovni32 commented 4 years ago

As the Teensy 4 is an interesting new platform I want to ask if there are plans to support Teensy 4 in upcoming versions?

ttlappalainen commented 4 years ago

Yes, there will be as soon as I have time.

ovni32 commented 4 years ago

These are good news - thanks!

hobiseven commented 4 years ago

HI there. Did you manage to progress a bit on Teensy 4.X port please? Thank you from France.

ttlappalainen commented 4 years ago

I have started it, but unfortunately have not worked so actively.

ovni32 commented 4 years ago

Dear Olivier,

I solved this topic in the following way by using a 3.2 and 4.0 Teensy in cooperation: I use a Teensy 3.2 to handle the NMEA200 bus. This Teensy 3.2 also uses sensors on an I2C bus (like environmental data pressure, temperature, wind) and forward the data to the NMEA 2000 bus. A LIN-bus is used to read out the IBS-sensors of my

batteries. The Teensy 3.2 also pushes these values to the NMEA2000 bus. Actually I am buying an heading sensor on an NMEA1830 basis, that will also operated by the Teensy 3.2.

I use the Teensy 4.0 to display the data on a 4” touch screen. This Teensy 4.0 gets the data via a serial port on its demand from the Teensy 3.2.

What is the advantage: The Teensy 3.2 has a significant lower power consumption than the 4.0 so that it runs all the time 7/24 and collects all data. I operate it further at low 24 MHz (less power, less heat). The Teensy 4.0 runs only when it is needed - and if it I runs it runs at full speed to get the needed graphical performance.

I tested this dual setup the last weeks on my ship and it works very fine. Probably this is also a solution for you. You only have to spend money for two Teensy.

Best Regards,

Markus

Von: Olivier Briand notifications@github.com Gesendet: Montag, 20. Juli 2020 21:36 An: ttlappalainen/NMEA2000 NMEA2000@noreply.github.com Cc: ovni32 markus@stommel.nrw; Comment comment@noreply.github.com Betreff: Re: [ttlappalainen/NMEA2000] Compiling on Teensy4.0 (#152)

HI there. Did you manage to progress a bit on Teensy 4.X port please? Thank you from France.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/ttlappalainen/NMEA2000/issues/152#issuecomment-661291668 , or unsubscribe https://github.com/notifications/unsubscribe-auth/AN7SRGCQCRIW4YQQDLLV223R4SMCRANCNFSM4I73LHHQ .

ttlappalainen commented 4 years ago

I have also looked in to the FlexCAN4 library and have thought that I have to clean it totally and include it to the new NMEA2000_Teensyx "driver". The FlexCAN4 has same issue as all CAN libraries they are not usable with NMEA2000, since they have only one output buffer, which destroys fastpacket sending. Other option is to send them with specific mailbox, which unfortunately stops system to wait until send has been done - and who in earth would like stop this great MCU to just wait. Also they forget message prioritizing totally. So I have clear plan and test device ready, just matter of time.

ttlappalainen commented 4 years ago

Does anyone have Teensy 4.x? I hope I'll have first driver version on next week. So I prefer other testers too.

pk1965 commented 4 years ago

@ttlappalainen I do.. its a 4.1 I've got transceivers for can0 and can1 and I'm currently sourcing canfd transcievers for can3. I've also have multiple other devices including a rpi4b with the 2 Channel CAN BUS FD shield we can test with

pk1965 commented 4 years ago

Successfully complied the new NMEA2000_Teensyx and updated NMEA2000 libraries on the following devices

Other Devices upgrade to the new NMEA2000 library only

When checking the can0 interface on RPI4-2 using the command "ip -details -statistics link show can0" i was seeing steadily increasing "bus-errors", "errer-wan" and "error-pass" counts when transmitting data on the teensy4.1. When I swapped the rolls between the Mega and 4.1 these errors stopped. Further investigation is needed to isolate the errors but i could just be my lab setup. Will advise when I have a more definitive idea whats happening.

So overall.. awesome work Timo for the first release.

ttlappalainen commented 4 years ago

Thaks a lot for good testing!

pk1965 commented 4 years ago

Your welcome

ttlappalainen commented 4 years ago

void SendTemperatureThread() { Sleep(2500); LockNMEA2000(); tN2kMsg N2kMsg; // Build message ... NMEA2000.SendMsg(N2kMsg); ReleaseNMEA2000(); }


usleep(100); is good hit, if it releases time to other threads. It drops CPU usage and has still very good timing resolution.
pk1965 commented 4 years ago

ok.. I'll see what I can find.

pk1965 commented 4 years ago

Sorry for the delay but my new TCAN330GD transceivers finally arrived allowing the checking with the CANFD port on the 4.1.

I've final started checking the fastpacket frames on MCP2515 controllers. It appears that the MCP2515 has the same issue on RPI devices as the Arduino mcp_can but the new "2 Channel CAN BUS FD Hat" (MCP2717FD) on for RPI doesnt. Note: The new "2 Channel CAN BUS FD Hat" is installed via a kernel module where the "CAN Bus Duo V2" uses the "SPI interface" and and overly in the /boot/config.txt"

My observations where based on the following setup;

  1. ListenerSender feeding data into the Actisence NMEA Reader on my PC.

    • Teensy 4.1 - integrated can controller / SN65HVD230DTI Can Bus transceiver for CAN2.0 ports can1//can2 and TCAN330GD CAN transceiver for the CANFD port can3.
    • Mega2560 - CAN-BUS Shield V2 MCP2515 Controller / MCP2551 CAN transceiver
  2. MessageSenders

    • RPI 4B - 2 Channel CAN BUS FD Hat (MCP2517FD) / MCP2557FD CAN transceiver
    • RPI3B+ - PiCAN 2 Duo MCP2515 Controller / MCP2551 CAN transceiver
    • Teensy 3.5 - integrated can controller / SN65HVD230DTI Can Bus transceiver

T4.1 listenerSender results:

  1. RPI3B - 28 PGN's seen only 7 being updated every second and heartbeat was every 60min
  2. RPI4B - 28PGN.s seen and all being updated every second except 127250/127488/129026 every 0.1sec and heartbeat every 60min
  3. Teensy 3.5 - 28PGN.s seen and all being updated every second except 127250/127488/129026 every 0.1sec and heartbeat every 60min

Mega2560 listernerSender results;

  1. RPI3B - 13PGN's seen with 7 being updated every second
  2. RPI4B - 22PGN's seen with 12 being updated every second
  3. Teensy 3.5 - 26PGN's seen all being updated every second except 127250/127488/129026 every 0.1sec and heartbeat every 60min

Here's a couple of snapshots below. SRC22 in the RPI4B and SRC40 is the RPI3B+ the MessagerSender app is identical and the Rasbian PI software. The first one is using the T4.1 as the ListenerSender and the second is the Mega2560.. notice the difference in the updates and the missing PGN's

SharedScreenshot

SharedScreenshot2

ttlappalainen commented 4 years ago

You could run MessageSender on T4 and RPi and listen with T3.5 and see the results.

pk1965 commented 4 years ago

done SRC22 is the RPI4B and SRC41 is the Teensy4.1 can3 SharedScreenshot3

ttlappalainen commented 4 years ago

Could you try with my NMEA Simulator and modified MessageSender http://www.kave.fi/Apps/NMEA2000/MessageSender.7z On Message sender send 'p' to pause sending messages and 'c' to clear stats and 'p' to continue sending. On NMEASimulator

Then

pk1965 commented 4 years ago

I repeated the test as requested on all 3 can ports on the 4.1 and the result was the same... failed message count=0 and the message count was the same

ttlappalainen commented 4 years ago

Sorry I mean to test it with RPi.

I have Teensy 3.2 on Simulator box receiving and I have tested sending with Teensy 3.2, 3.5, 4.0 and ESP32. Also with 3 divices sending sumulatanous. But interisting is that if you send from RPi. I have not cheked how they handle frames on RPi. On CAN controller it is possibele to use multiple Mailbox, but fastpackets has to be forced to go out from same. If not frames may be mixed and my listener program skips them.

pk1965 commented 4 years ago

Ok bare with me whilst I port it over to the RPI

pk1965 commented 4 years ago

very interesting results. I complied and run the software on all three RPI's and using the T4.1 as the listenerSender.. There was no lost messages even when all three devices where transmitting at the same time. There was a throughput difference of about 10% when changing between the CANFD port to a CAN2.0 port on the T4.1.

ttlappalainen commented 4 years ago

What do you mean with "throughput difference of about 10%"? How did you measure it and which was better?