Skip to content

Commit

Permalink
2.6.6
Browse files Browse the repository at this point in the history
  • Loading branch information
Trusty77 committed Sep 23, 2024
1 parent c01b291 commit 0a04d5d
Show file tree
Hide file tree
Showing 9 changed files with 50 additions and 51 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
.vscode/launch.json
.vscode/ipch
config.h

16 changes: 8 additions & 8 deletions CanMarklin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ void ackTask(void *pvParameters)
if (status == pdPASS)
{
frame.id &= ~0xFFFF;
frame.id |= 1 << 17; // R�ponse
frame.id |= 1 << 17; // Réponse
frame.id |= CanMarklin::getId(); // ID expediteur
CanMarklin::sendMsg(frame);
}
Expand Down Expand Up @@ -97,10 +97,10 @@ void CanMarklin::loop()
CANMessage frameIn;
if (ACAN_ESP32::can.receive(frameIn))
{
const uint8_t prio = (frameIn.id & 0x1E000000) >> 25; // Priorit�
const uint8_t prio = (frameIn.id & 0x1E000000) >> 25; // Priorité
const uint8_t cmde = (frameIn.id & 0x1FE0000) >> 17; // Commande
const uint8_t resp = (frameIn.id & 0x10000) >> 16; // Reponse
const uint16_t exped = (frameIn.id & 0xFFFF); // Exp�diteur
const uint16_t exped = (frameIn.id & 0xFFFF); // Expéditeur

char cmdName[20];
switch (cmde)
Expand Down Expand Up @@ -140,7 +140,7 @@ void CanMarklin::loop()
locoAddress = (frameIn.data[0] << 24) | (frameIn.data[1] << 16) | (frameIn.data[2] << 8) | frameIn.data[3];

/*
Cas particulier de la MS2 en attendant d'avoir d�velopp� les commandes MFX Bind
Cas particulier de la MS2 en attendant d'avoir développé les commandes MFX Bind
*/

// if (locoAddress >= 0x4000 && locoAddress < 0x7FFF)
Expand Down Expand Up @@ -175,7 +175,7 @@ void CanMarklin::loop()
// Serial.println(loco->gDirection());
}

switch (cmde) // Commande appel�e
switch (cmde) // Commande appelée
{
case CAN_LOCO_SPEED:
if (loco != nullptr)
Expand All @@ -192,10 +192,10 @@ void CanMarklin::loop()
xQueueSendToBack(xQueue, &frameIn, 0);
break;
case CAN_LOCO_DIREC:
// Signification du param�tre Direction :
// Signification du paramètre Direction :
// 0 = sens de marche sans changement
// 1 = sens de marche avant
// 2 = sens de marche arri�re
// 2 = sens de marche arrière
// 3 = inverser le sens de marche

if (loco != nullptr)
Expand All @@ -210,7 +210,7 @@ void CanMarklin::loop()
loco->sSpeed(0);
break;
case 2:
loco->sDirection(0); // Arri�re
loco->sDirection(0); // Arrière
loco->sSpeed(0);
break;
case 3:
Expand Down
10 changes: 5 additions & 5 deletions CanMarklin.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@
#define VERSION_LABOX_CAN "0.7.3"
// 0.7.3 - 12/09/24 : Modification du filtre ACAN_ESP32_Filter
// 0.7.2 - 07/09/24 : Optimisatin de la recherche findLoco de la classe CanMarklinLoco
// 0.7.1 - 05/09/24 : Modifications importantes pour les codes de commandes Respect précis du protocole Marklin
// 0.7.0 - 26/08/24 : Passage à EXComm
// 0.6.4 - 29/03/24 : Reformattage léger avec remplacement des commandes hexa par des defines.
// 0.7.1 - 05/09/24 : Modifications importantes pour les codes de commandes Respect précis du protocole Marklin
// 0.7.0 - 26/08/24 : Passage à EXComm
// 0.6.4 - 29/03/24 : Reformattage léger avec remplacement des commandes hexa par des defines.
// utilisation du define CAN pour exclure la compilation de ces sources
// utilisation de DIAG pour les messages à la console.
// 0.6.3 - 21/02/24 : Modification des identifiants de messages CAN
Expand Down Expand Up @@ -65,9 +65,9 @@ class CanMarklinLoco
bool direction;

public:
// Constructeur par défaut
// Constructeur par défaut
CanMarklinLoco() : address(0), speed(0), direction(1) {}
// Constructeur avec paramètre adresse
// Constructeur avec paramètre adresse
CanMarklinLoco(uint32_t addr) : address(addr), direction(1) {}

void sAddress(uint32_t address) { this->address = address; }
Expand Down
7 changes: 2 additions & 5 deletions StringFormatter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,9 @@
#include "DisplayInterface.h"

bool Diag::ACK=false;
bool Diag::CMD=true;
bool Diag::WIFI=true;
bool Diag::CMD=false;
bool Diag::WIFI=false;
bool Diag::WITHROTTLE=false;
bool Diag::Z21THROTTLE=false;
bool Diag::Z21THROTTLEVERBOSE=false;
bool Diag::Z21THROTTLEDATA=false;
bool Diag::ETHERNET=false;
bool Diag::LCN=false;

Expand Down
3 changes: 0 additions & 3 deletions StringFormatter.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@ class Diag {
static bool CMD;
static bool WIFI;
static bool WITHROTTLE;
static bool Z21THROTTLE;
static bool Z21THROTTLEVERBOSE;
static bool Z21THROTTLEDATA;
static bool ETHERNET;
static bool LCN;

Expand Down
2 changes: 0 additions & 2 deletions WifiESP32.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -366,8 +366,6 @@ void WifiESP::loop() {
}
} // all clients

// UDP clients

WiThrottle::loop(outboundRing);

// something to write out?
Expand Down
45 changes: 23 additions & 22 deletions Z21Throttle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,13 @@

static std::vector<NetworkClientUDP> clientsUDP; // a list to hold all UDP clients

#define DIAG_Z21 if (Diag::Z21THROTTLE) DIAG
#define DIAG_Z21DATA if (Diag::Z21THROTTLEDATA) DIAG
#define DIAG_Z21VERBOSE if (Diag::Z21THROTTLEVERBOSE) DIAG
bool Z21Throttle::Z21THROTTLE=false;
bool Z21Throttle::Z21THROTTLEVERBOSE=false;
bool Z21Throttle::Z21THROTTLEDATA=false;

#define DIAG_Z21 if (Z21Throttle::Z21THROTTLE) DIAG
#define DIAG_Z21DATA if (Z21Throttle::Z21THROTTLEDATA) DIAG
#define DIAG_Z21VERBOSE if (Z21Throttle::Z21THROTTLEVERBOSE) DIAG

#define LOOPLOCOS(THROTTLECHAR, CAB) for (int loco=0;loco<MAX_MY_LOCO;loco++) \
if ((myLocos[loco].throttle==THROTTLECHAR || '*'==THROTTLECHAR) && (CAB<0 || myLocos[loco].cab==CAB))
Expand All @@ -65,22 +69,19 @@ bool Z21EXCommItem::beginItem() {
#ifdef DCCPP_DEBUG_MODE
CircularBuffer::Test();
#endif
bool retf = false;
bool retf = true;

if (WiFi.status() == WL_CONNECTED) {
IPAddress ip;
IPAddress ip;

if (WiFi.getMode() == wifi_mode_t::WIFI_MODE_STA)
ip = WiFi.localIP();
if (WiFi.getMode() == wifi_mode_t::WIFI_MODE_AP)
ip = WiFi.softAPIP();
if (WiFi.getMode() == wifi_mode_t::WIFI_MODE_STA)
ip = WiFi.localIP();
if (WiFi.getMode() == wifi_mode_t::WIFI_MODE_AP)
ip = WiFi.softAPIP();

uint8_t ret = NetworkClientUDP::client.begin(ip, UDPport);
if (ret == 1) {
retf = true;
uint8_t ret = NetworkClientUDP::client.begin(ip, UDPport);
if (ret == 1) {
retf = true;
NetworkClientUDP::client.flush();
}
NetworkClientUDP::client.flush();
}

if (retf)
Expand Down Expand Up @@ -108,12 +109,12 @@ int readUdpPacket() {
if (len < Z21_MAXIMAL_UDP_MSG_SIZE) {
clientsUDP[clientId].pudpBuffer->PushBytes(udp, len);

//if (Diag::Z21THROTTLEDATA) clientsUDP[clientId].pudpBuffer->printStatus();
//if (Z21Throttle::Z21THROTTLEDATA) clientsUDP[clientId].pudpBuffer->printStatus();
}
else {
DIAG_Z21(F("[Z21] %d <- long message ignored : udp_len:%d first byte : %d"), clientId, len, udp[0]);

if (Diag::Z21THROTTLEDATA) {
if (Z21Throttle::Z21THROTTLEDATA) {
for(int i = 0; i < 10; i++) {
if (len > i*10) {
DIAG_Z21DATA(F("[Z21] UDP %d-%d : 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x"),
Expand Down Expand Up @@ -143,7 +144,7 @@ int readUdpPacket() {
}

void Z21Throttle::loop() {
if (WiFi.status() != WL_CONNECTED || Z21EXCommItem::UDPport < 0) {
if (Z21EXCommItem::UDPport < 0) {
return;
}

Expand Down Expand Up @@ -234,7 +235,7 @@ void Z21Throttle::loop() {

/** Print the list of assigned locomotives. */
void Z21Throttle::printLocomotives(bool addTab) {
if (!Diag::Z21THROTTLE)
if (!Z21Throttle::Z21THROTTLE)
return;

DIAG(F("[Z21] Locomotives ------------------"));
Expand All @@ -245,7 +246,7 @@ void Z21Throttle::printLocomotives(bool addTab) {

/** Print the list of assigned locomotives. */
void printClientsUDP() {
if (!Diag::Z21THROTTLE) return;
if (!Z21Throttle::Z21THROTTLE) return;

DIAG(F("[Z21] UDP Clients ------------------"));
for (int clientId = 0; clientId < clientsUDP.size(); clientId++)
Expand All @@ -257,7 +258,7 @@ void printClientsUDP() {

/** Print the list of assigned locomotives. */
void Z21Throttle::printThrottles(bool inPrintLocomotives) {
if (!Diag::Z21THROTTLE) return;
if (!Z21Throttle::Z21THROTTLE) return;

DIAG(F("[Z21] Throttles ---------------"));
for (Z21Throttle* wt = firstThrottle; wt != NULL; wt = wt->nextThrottle) {
Expand Down Expand Up @@ -834,7 +835,7 @@ bool Z21Throttle::parse() {
case LAN_X_DB0_SET_LOCO_FUNCTION:
DIAG_Z21VERBOSE(F("[Z21] %d LOCO DCC FUNCTION"), this->clientid);
setFunction(DB[2], DB[3], DB[4]);
if (Diag::Z21THROTTLE) {
if (Z21Throttle::Z21THROTTLE) {
// Debug capacity to print data...
byte function = DB[4];
bitClear(function, 6);
Expand Down
6 changes: 5 additions & 1 deletion Z21Throttle.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,11 @@ class Z21Throttle {
static int cvAddress;
static int cvValue;

private:
static bool Z21THROTTLE;
static bool Z21THROTTLEVERBOSE;
static bool Z21THROTTLEDATA;

private:
Z21Throttle(int clientId);
~Z21Throttle();

Expand Down
11 changes: 6 additions & 5 deletions version_labox.h
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
#ifndef version_labox_h
#define version_labox_h

#define VERSION_LABOX "2.6.5"
// 2.6.5 - Reduce imprint of Railcom code in DCCRMT.c
#define VERSION_LABOX "2.6.6"
// 2.6.6 - Fix AP WiFi mode for Z21 and WiThrottle.
// 2.6.5 - Reduce imprint of Railcom code in DCCRMT.cpp
// - Improvements in CanMarklin
// - First CAN message shows its version.
// - New PCB with lots of changed attributes nedded by the BOM and placement files.
// - Gerber files are now in Kicad/Fabrication instead of Gerber.
// - New Gerber files of the PCB with BOM files generated by the 'Fabrication Toolkit' plugin of Kicad for JLCPCB.
// - [PCB] New PCB with lots of changed attributes nedded by the BOM and placement files.
// - [PCB] Gerber files are now in Kicad/Fabrication instead of Gerber.
// - [PCB] New Gerber files of the PCB with BOM files generated by the 'Fabrication Toolkit' plugin of Kicad for JLCPCB.
// 2.6.4 - Fix XpressNet.cpp file format.
// - Try to fix the crash on some ESP32 when RailCom and CAN are both activated.
// Dont know why this modification works, but it works !
Expand Down

0 comments on commit 0a04d5d

Please sign in to comment.