Closed Tinyu-Zhao closed 5 months ago
hi Tinyu,
thanks for pointing out that bug to me! I confirm that I see the same error message, and the fix is rather straightforward. Can you please change in lines 14+15
#include "LIN_master0.h"
#include "LIN_master1.h"
to
#include "LIN_master1.h"
#include "LIN_master2.h"
and re-check? If that works for you, I will upload the change and trigger a new release. Thanks a lot in advance!
PS: this library in only compatible with the old ATMega controllers. Triggered by requests to support other boards as well, I have added another LIN library, which might be of interest to you...?
I think it needs to be changed to // LIN master library
This will avoid errors. LIN_master0~LIN_master2 all appear in the program.
I will try the new library, which may help me. I also want to ask, there is no LIN slave library available. I now want to let one machine act as the LIN master to send signals, and the other as the LIN slave to receive the LIN signal sent by the master to verify whether TJA1021 can work properly (I don’t have a device that can actually generate LIN signals)
ad 1) the example should only use Serial1 and Serial2, as Serial(0) is used for console output (see line 43). But you are correct, there is another error: in lines 46+47 please change
LIN_master0.begin(19200, LIN_V2, true);
LIN_master1.begin(9600, LIN_V1, true);
to
LIN_master1.begin(19200, LIN_V2, true);
LIN_master2.begin(9600, LIN_V1, true);
and let me know if this is now ok. Thanks in advance!
ad 2) the problem with Arduino and LIN slave is that the native Serial library misses the following, required features
HOWEVER, the TJA1021 is a simply transceiver without fancy logic. Therefore you can simply test it by sending bytes and receiving them. No need for LIN protocol... Let me know if this helps
ad 1) the example should only use Serial1 and Serial2, as Serial(0) is used for console output (see line 43). But you are correct, there is another error: in lines 46+47 please change
LIN_master0.begin(19200, LIN_V2, true); LIN_master1.begin(9600, LIN_V1, true);
to
LIN_master1.begin(19200, LIN_V2, true); LIN_master2.begin(9600, LIN_V1, true);
and let me know if this is now ok. Thanks in advance!
ad 2) the problem with Arduino and LIN slave is that the native Serial library misses the following, required features
- user interrupt handlers, which is required for timing
- store UART framing errors, which is required to detect a SYNC break
HOWEVER, the TJA1021 is a simply transceiver without fancy logic. Therefore you can simply test it by sending bytes and receiving them. No need for LIN protocol... Let me know if this helps
Now this error is gone, but the prompt
lib/arduino-tasks/Tasks.cpp:11:10: fatal error: avr/power.h: No such file or directory
#include <avr/power.h>
^~~~~~~~~~~~~~
compilation terminated.
I use esp32 because I saw in the readme interface that it can support esp32
I mainly want to verify whether the lin function of the chip is available, so simple byte transmission and reception should not be possible
Ad 1)
I use esp32 because I saw in the readme interface that it can support esp32
Ah, I wasn't aware of that and didn't re-check. Sorry! However, I checked for ESP32-WROOM-DA
and LOLIN(WEMOS) D1 mini
and found this:
However, your error for ESP32 seems to be in library lib/arduino-tasks/Tasks.cpp
, not in my LIN library, correct? Note that for ESP32 I use the library Ticker
instead of Tasks
, see example dual_LIN
, line 21. Does this solve your problem?
Ad 2)
I mainly want to verify whether the lin function of the chip is available, so simple byte transmission and reception should not be possible
I don't understand. TJA1021 is a dumb transceiver without protocol handler. If you can send & receive a byte, it already proves that the chip is working. The difference to LIN is only the leading SYNC break (=0x00 at 1/2 baudrate) and the protocol. Both are generated and evaluated by the µC, not the TJA1021. What am I missing?
You are right, but it is very strange. It is clearly identified as the esp32 development version in platformio, and include "Tasks.h" has been "dimmed", but I still get this error unless I delete it.
After delete, work great.
Maybe I misunderstood this chip, thank you for your tip.
I use Arduino-IDE for testing my libraries, because it is mainstream. To me it looks like that's a problem with the macro handling of platformio. Because if the code is grayed out in the editor, it should be skipped during build. Maybe you issue a bug report for platformio?
Can I close this issue and release the fixed library?
I use Arduino-IDE for testing my libraries, because it is mainstream. To me it looks like that's a problem with the macro handling of platformio. Because if the code is grayed out in the editor, it should be skipped during build. Maybe you issue a bug report for platformio?我使用 Arduino-IDE 来测试我的库,因为它是主流。对我来说,这似乎是平台 IO 宏处理的问题。因为如果代码在编辑器中变灰,它应该在构建过程中被跳过。也许你可以为平台 IO 发布一个错误报告?
Can I close this issue and release the fixed library?我可以关闭这个问题并发布修复后的库吗?
Sure, thank you for your help!
https://github.com/gicking/LIN_master_Arduino/blob/700a1950caecd001518cd6d002cef360ccca4910/examples/dual_LIN/dual_LIN.ino
src/main.cpp:87:9: error: 'LIN_master2' was not declared in this scope if (LIN_master2.getState() != LIN_STATE_IDLE) return; ^
~~src/main.cpp:87:9: note: suggested alternative: 'LIN_master1' if (LIN_master2.getState() != LIN_STATE_IDLE) return; ^~~LIN_master1 src/main.cpp:97:5: error: 'LIN_master2' was not declared in this scope LIN_master2.sendMasterRequest(id, lenData, data); ^~~src/main.cpp:97:5: note: suggested alternative: 'LIN_master1' LIN_master2.sendMasterRequest(id, lenData, data); ^~~LIN_master1