mirror of
https://github.com/DCC-EX/CommandStation-EX.git
synced 2024-11-26 17:46:14 +01:00
Passing Strteamer correctly
Previous method copied entire buffer!!!!
This commit is contained in:
parent
8ff947f895
commit
b7fc055953
|
@ -27,5 +27,5 @@ void CommandDistributor::parse(byte clientId,byte * buffer, RingStream * stream
|
||||||
if (!parser) parser = new DCCEXParser();
|
if (!parser) parser = new DCCEXParser();
|
||||||
parser->parse(streamer, buffer, true); // tell JMRI parser that ACKS are blocking because we can't handle the async
|
parser->parse(streamer, buffer, true); // tell JMRI parser that ACKS are blocking because we can't handle the async
|
||||||
}
|
}
|
||||||
else WiThrottle::getThrottle(clientId)->parse(*streamer, buffer);
|
else WiThrottle::getThrottle(clientId)->parse(streamer, buffer);
|
||||||
}
|
}
|
||||||
|
|
|
@ -99,7 +99,7 @@ WiThrottle::~WiThrottle() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void WiThrottle::parse(RingStream & stream, byte * cmdx) {
|
void WiThrottle::parse(RingStream * stream, byte * cmdx) {
|
||||||
|
|
||||||
byte * cmd=cmdx;
|
byte * cmd=cmdx;
|
||||||
|
|
||||||
|
@ -205,7 +205,7 @@ int WiThrottle::getLocoId(byte * cmd) {
|
||||||
if (cmd[0]!='L' && cmd[0]!='S') return 0; // should not match any locos
|
if (cmd[0]!='L' && cmd[0]!='S') return 0; // should not match any locos
|
||||||
return getInt(cmd+1);
|
return getInt(cmd+1);
|
||||||
}
|
}
|
||||||
void WiThrottle::multithrottle(Print & stream, byte * cmd){
|
void WiThrottle::multithrottle(RingStream * stream, byte * cmd){
|
||||||
char throttleChar=cmd[1];
|
char throttleChar=cmd[1];
|
||||||
int locoid=getLocoId(cmd+3); // -1 for *
|
int locoid=getLocoId(cmd+3); // -1 for *
|
||||||
byte * aval=cmd;
|
byte * aval=cmd;
|
||||||
|
@ -256,7 +256,7 @@ void WiThrottle::multithrottle(Print & stream, byte * cmd){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void WiThrottle::locoAction(Print & stream, byte* aval, char throttleChar, int cab){
|
void WiThrottle::locoAction(RingStream * stream, byte* aval, char throttleChar, int cab){
|
||||||
// Note cab=-1 for all cabs in the consist called throttleChar.
|
// Note cab=-1 for all cabs in the consist called throttleChar.
|
||||||
// DIAG(F("\nLoco Action aval=%c%c throttleChar=%c, cab=%d"), aval[0],aval[1],throttleChar, cab);
|
// DIAG(F("\nLoco Action aval=%c%c throttleChar=%c, cab=%d"), aval[0],aval[1],throttleChar, cab);
|
||||||
switch (aval[0]) {
|
switch (aval[0]) {
|
||||||
|
@ -334,12 +334,13 @@ int WiThrottle::WiTToDCCSpeed(int WiTSpeed) {
|
||||||
return WiTSpeed + 1; //offset others by 1
|
return WiTSpeed + 1; //offset others by 1
|
||||||
}
|
}
|
||||||
|
|
||||||
void WiThrottle::loop(RingStream & stream) {
|
void WiThrottle::loop(RingStream * stream) {
|
||||||
// for each WiThrottle, check the heartbeat
|
// for each WiThrottle, check the heartbeat
|
||||||
for (WiThrottle* wt=firstThrottle; wt!=NULL ; wt=wt->nextThrottle)
|
for (WiThrottle* wt=firstThrottle; wt!=NULL ; wt=wt->nextThrottle)
|
||||||
wt->checkHeartbeat();
|
wt->checkHeartbeat();
|
||||||
|
|
||||||
// TODO... any broadcasts to be done
|
// TODO... any broadcasts to be done
|
||||||
|
(void)stream;
|
||||||
/* MUST follow this model in this loop.
|
/* MUST follow this model in this loop.
|
||||||
* stream->mark();
|
* stream->mark();
|
||||||
* send 1 digit client id, and any data
|
* send 1 digit client id, and any data
|
||||||
|
|
10
WiThrottle.h
10
WiThrottle.h
|
@ -28,8 +28,8 @@ struct MYLOCO {
|
||||||
|
|
||||||
class WiThrottle {
|
class WiThrottle {
|
||||||
public:
|
public:
|
||||||
static void loop(RingStream & stream);
|
static void loop(RingStream * stream);
|
||||||
void parse(RingStream & stream, byte * cmd);
|
void parse(RingStream * stream, byte * cmd);
|
||||||
static WiThrottle* getThrottle( int wifiClient);
|
static WiThrottle* getThrottle( int wifiClient);
|
||||||
static bool annotateLeftRight;
|
static bool annotateLeftRight;
|
||||||
private:
|
private:
|
||||||
|
@ -57,9 +57,9 @@ class WiThrottle {
|
||||||
bool lastPowerState; // last power state sent to this client
|
bool lastPowerState; // last power state sent to this client
|
||||||
int DCCToWiTSpeed(int DCCSpeed);
|
int DCCToWiTSpeed(int DCCSpeed);
|
||||||
int WiTToDCCSpeed(int WiTSpeed);
|
int WiTToDCCSpeed(int WiTSpeed);
|
||||||
void multithrottle(Print & stream, byte * cmd);
|
void multithrottle(RingStream * stream, byte * cmd);
|
||||||
void locoAction(Print & stream, byte* aval, char throttleChar, int cab);
|
void locoAction(RingStream * stream, byte* aval, char throttleChar, int cab);
|
||||||
void accessory(Print & stream, byte* cmd);
|
void accessory(RingStream *, byte* cmd);
|
||||||
void checkHeartbeat();
|
void checkHeartbeat();
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue
Block a user