mrrwa / loconet2 Goto Github PK
View Code? Open in Web Editor NEWA refactor of the original library to be much more object oriented, with derived classes for each different hardware interface
A refactor of the original library to be much more object oriented, with derived classes for each different hardware interface
I have started trying to port the Loconet library to Arduiono Nano Every. Right now it seems to me that there are enough differnces between the avr and avrmega ICPs so that it will require more changes than simply adding avrmega specific defines in ln_config.h ,
Would it make more sense to do this development in this library instead of the old codebase?
What is the ambitions for the two different Loconet libraries? Is the intention for Loconet2 to be the way forward and replace the old one?
Hello!
I'm trying to use and modify this library for my purposes and noticed that I cannot send packets from inside notify...
methods, this makes responding to requests problematic. The issue is due to actual sending bits and receiving bits happens in the same freertos task and while(lnState == LN_ST_TX)
loop inside sendLocoNetPacketTry
basically blocks the task it's running on. When one calls send
method from notify...
function, that loops basically deadlocks the sending task.
I think it would be better to move actual bit sending (and receiving) to timer functions and only handle receiving of bytes in the task. This way, waiting for send to complete won't block sending which is done in timers.
Also, what's the development status of this library? I've noticed that it hasn't been updated for a while.
Unlike the AVR library, because of the way the receive/transmit task's state machine works, you don't receive your own transmissions to Loconet.
I have been experimenting with amending the code to add the bits into the receive byte buffer (lnCurrentRxByte
), and shifting them as the receive code does, as they are put onto the bus.
When a byte has been transmitted, and the transmit task gets the next byte, process(lnCurrentRxByte)
method is called, to build the message up the main Loconet message buffer as if it was receiving a byte normally.
In the case of a collision, the lnCurrentRxByte
is cleared ready for either retrying transmission or receiving a byte from the bus.
My tests show this is working, and the notifyX
functions get called as expected. So, for example, I can transmit a SwitchRequest message, get notified and act on it on the same ESP32.
I'm sure there are cases where this won't work, and I need to see what happens if a collision happens in the middle of a multi-byte message, where some bytes are already in the main Loconet message buffer (although I guess this can happen when receiving too, so this may not be a problem).
Thanks,
Richard
Hi,
I'm trying to compile the 'Basic-Listener-Pico.ino' but this gives the error: 'LocoNetStreamPico' does not name a type;
I also get a WARNING: library LocoNet2 claims to run on esp32 architecture(s) and may be incompatible with your current board which runs on rp2040 architecture(s).
Like to use LocoNet2 on a RPi Pico W as a router to MQTT.
Hello,
i want to setup a Throttle with an ESP32. but in the Init phase the CPU looks up.
I habve an NodeMUC ESP-32s wiht an ESP-Wroom32 Chip. Some other Tests with TFT ans so an are ok.
I have the Arduino IDE with the last ESP 1.0.1 installed. (Updated after the problem beginns)
For me its crash at Throttle.init (0,0,0, ThrottleID); //erzeuge Handregler
I don't know whats wrong.
Any change to help ?
Tank you very mutch for a hint.
Jake
`
#include <LocoNetESP32.h>
uint16_t ThrottleID = 0x20;
#define SpeedMax 127 //höchste Geschwindigkeit. (vielleicht auch hier Stufen nutzen -> FredI!)
long unsigned int LastThrottleTimerTick;
word Adresse = 1; // default Adresse 16-bit
byte Slot = 0xFF; // akt. Slot zur Adr. (kein)
byte AdrH = 0; // high Anteil Adresse
byte AdrL = 0; // low Anteil Adresse
LocoNetESP32Class LocoNet;
LocoNetThrottleClass Throttle;
void setup(void)
{
Serial.begin(115200);
Serial.println("Setup Start");
//### Loconet Init
Serial.println("Init");
LocoNet.init(); // First initialize the LocoNet interface
Serial.println("Throttle");
Throttle.init (0,0,0, ThrottleID); //erzeuge Handregler
Serial.println("Throttle OK");
Serial.println("Setup END");
}
//--------------------------------------------------------------------------------------------------
void loop() {
//AdrL = Adresse; //Adresse in je 2x 8 Bit Speichen für EEPROM Sicherung
//AdrH = Adresse >> 8;
}
`
10:45:34.806 -> rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
10:45:34.806 -> configsip: 0, SPIWP:0xee
10:45:34.806 -> clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
10:45:34.806 -> mode:DIO, clock div:1
10:45:34.806 -> load:0x3fff0018,len:4
10:45:34.806 -> load:0x3fff001c,len:1100
10:45:34.806 -> load:0x40078000,len:10088
10:45:34.806 -> load:0x40080400,len:6380
10:45:34.806 -> entry 0x400806a4
10:45:34.966 -> Setup Start
10:45:34.966 -> Init
10:45:34.966 -> LocoNetESP32Class Initialising
10:45:34.966 -> Throttle
10:45:34.966 -> Guru Meditation Error: Core 1 pan⸮ets Jun 8 2016 00:22:57
⸮ets Jun 8 2016 00:22:57
10:45:35.046 ->
10:45:35.046 -> rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
10:45:35.046 -> configsip: 0, SPIWP:0xee
10:45:35.046 -> clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
10:45:35.046 -> mode:DIO, clock div:1
10:45:35.046 -> load:0x3fff0018,len:4
10:45:35.046 -> load:0x3fff001c,len:1100
10:45:35.046 -> load:0x40078000,len:10088
10:45:35.046 -> load:0x40080400,len:6380
10:45:35.046 -> entry 0x400806a4
10:45:35.206 -> Setup Start
10:45:35.206 -> Init
10:45:35.206 -> LocoNetESP32Class Initialising
10:45:35.206 -> Throttle
10:45:35.206 -> Guru Meditation Error: Core 1 panic'ed (LoadProhibited). Exception was unhandled.
10:45:35.206 -> Core 1 register dump:
10:45:35.206 -> PC : 0x400e9f37 PS : 0x00060130 A0 : 0x800d0c5c A1 : 0x3ffb1f60
10:45:35.206 -> A2 : 0x3ffbfcf0 A3 : 0x00000000 A4 : 0x00000000 A5 : 0x00000000
10:45:35.206 -> A6 : 0x00000020 A7 : 0x00000000 A8 : 0x800d1d30 A9 : 0x3ffb1f40
10:45:35.246 -> A10 : 0x00000002 A11 : 0x3f400031 A12 : 0x00000001 A13 : 0x00000000
10:45:35.246 -> A14 : 0xe03c1000 A15 : 0x3ff5f000 SAR : 0x0000001c EXCCAUSE: 0x0000001c
10:45:35.246 -> EXCVADDR: 0x00000030 LBEG : 0x400014fd LEND : 0x4000150d LCOUNT : 0xffffffff
10:45:35.246 ->
10:45:35.246 -> Backtrace: 0x400e9f37:0x3ffb1f60 0x400d0c59:0x3ffb1f80 0x400d2abb:0x3ffb1fb0 0x40089a09:0x3ffb1fd0
10:45:35.246 ->
10:45:35.246 -> Rebooting...
10:45:35.286 -> ets Jun 8 2016 00:22:57
10:45:35.286 ->
10:45:35.286 -> rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
10:45:35.286 -> configsip: 0, SPIWP:0xee
10:45:35.286 -> clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
10:45:35.286 -> mode:DIO, clock div:1
10:45:35.286 -> load:0x3fff0018,len:4
10:45:35.286 -> load:0x3fff001c,len:1100
10:45:35.286 -> load:0x40078000,len:10088
10:45:35.286 -> load:0x40080400,len:6380
10:45:35.286 -> entry 0x400806a4
10:45:35.434 -> Setup Start
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.