12 #include "TextCommand.h" 13 #ifdef USE_TEXTCOMMAND 18 extern unsigned int __heap_start;
19 extern void *__brkval;
24 char TextCommand::commandString[MAX_COMMAND_LENGTH+1];
34 void TextCommand::process(){
37 #if defined(USE_ETHERNET) 39 EthernetClient client=INTERFACE.available();
43 if (DCCppConfig::Protocol == EthernetProtocol::HTTP) {
44 INTERFACE.println(
"HTTP/1.1 200 OK");
45 INTERFACE.println(
"Content-Type: text/html");
46 INTERFACE.println(
"Access-Control-Allow-Origin: *");
47 INTERFACE.println(
"Connection: close");
48 INTERFACE.println(
"");
51 while (client.connected() && client.available()) {
57 else if (strlen(commandString) < MAX_COMMAND_LENGTH)
58 sprintf(commandString,
"%s%c", commandString, c);
61 if (DCCppConfig::Protocol == EthernetProtocol::HTTP)
67 while (INTERFACE.available()>0) {
73 else if (strlen(commandString) < MAX_COMMAND_LENGTH)
74 sprintf(commandString,
"%s%c", commandString, c);
83 void TextCommand::parse(
char *com){
86 #ifdef DCCPP_DEBUG_MODE 88 Serial.println(F(
" command"));
114 DCCpp::mainRegs.setThrottle(com+1);
162 DCCpp::mainRegs.setFunction(com+1);
201 DCCpp::mainRegs.setAccessory(com+1);
236 #ifdef DCCPP_PRINT_DCCPP 277 DCCpp::mainRegs.writeCVByteMain(com+1);
302 DCCpp::mainRegs.writeCVBitMain(com+1);
327 DCCpp::progRegs.writeCVByte(com+1);
353 DCCpp::progRegs.writeCVBit(com+1);
377 DCCpp::progRegs.readCV(com+1);
435 INTERFACE.print(
"<a");
437 INTERFACE.print(
">");
438 #if !defined(USE_ETHERNET) 439 INTERFACE.println(
"");
460 if(digitalRead(DCCppConfig::SignalEnablePinProg)==LOW)
461 INTERFACE.print(
"<p0>");
463 INTERFACE.print(
"<p1>");
464 #if !defined(USE_ETHERNET) 465 INTERFACE.println(
"");
468 for(
int i=1;i<=MAX_MAIN_REGISTERS;i++){
469 if(DCCpp::mainRegs.speedTable[i]==0)
471 INTERFACE.print(
"<T");
472 INTERFACE.print(i); INTERFACE.print(
" ");
473 if(DCCpp::mainRegs.speedTable[i]>0){
474 INTERFACE.print(DCCpp::mainRegs.speedTable[i]);
475 INTERFACE.print(
" 1>");
477 INTERFACE.print(- DCCpp::mainRegs.speedTable[i]);
478 INTERFACE.print(
" 0>");
480 #if !defined(USE_ETHERNET) 481 INTERFACE.println(
"");
484 INTERFACE.print(
"<iDCCpp LIBRARY BASE STATION FOR ARDUINO ");
488 INTERFACE.print(
": V-");
489 INTERFACE.print(VERSION);
490 INTERFACE.print(
" / ");
491 INTERFACE.print(__DATE__);
492 INTERFACE.print(
" ");
493 INTERFACE.print(__TIME__);
494 INTERFACE.print(
">");
495 #if !defined(USE_ETHERNET) 496 INTERFACE.println(
"");
499 INTERFACE.print(
"<N ");
500 #if defined(USE_ETHERNET) 501 INTERFACE.print(
"ETHERNET :");
502 INTERFACE.print(Ethernet.localIP());
503 INTERFACE.print(
">");
504 #if !defined(USE_ETHERNET) 505 INTERFACE.println(
"");
508 INTERFACE.println(
"SERIAL>");
511 #ifdef DCCPP_PRINT_DCCPP 542 INTERFACE.print(
"<e ");
544 INTERFACE.print(
" ");
546 INTERFACE.print(
" ");
548 INTERFACE.print(
">");
549 #if !defined(USE_ETHERNET) 550 INTERFACE.println(
"");
571 INTERFACE.print(
"<O>");
572 #if !defined(USE_ETHERNET) 573 INTERFACE.println(
"");
594 INTERFACE.println(
"");
617 Serial.println(
"nEntering Diagnostic Mode...");
620 bitClear(TCCR1B,CS12);
622 bitClear(TCCR1B,CS10);
624 #if defined(ARDUINO_AVR_UNO) || defined(ARDUINO_AVR_NANO) // Configuration for UNO 627 bitClear(TCCR0B,CS01);
628 bitClear(TCCR0B,CS00);
630 #else // Configuration for MEGA 632 bitClear(TCCR3B,CS32);
634 bitClear(TCCR3B,CS30);
667 DCCpp::mainRegs.writeTextPacket(com+1);
694 DCCpp::progRegs.writeTextPacket(com+1);
718 INTERFACE.print(
"<f");
719 INTERFACE.print((
int) &v - (__brkval == 0 ? (
int) &__heap_start : (
int) __brkval));
720 INTERFACE.print(
">");
721 #if !defined(USE_ETHERNET) 722 INTERFACE.println(
"");
742 INTERFACE.println(
"");
743 for(
Register *p = DCCpp::mainRegs.reg; p <= DCCpp::mainRegs.maxLoadedReg;p++){
744 INTERFACE.print(
"M"); INTERFACE.print((
int)(p - DCCpp::mainRegs.reg)); INTERFACE.print(
":t");
745 INTERFACE.print((
int)p); INTERFACE.print(
"t");
746 INTERFACE.print((
int)(p->activePacket)); INTERFACE.print(
"t");
747 INTERFACE.print(p->activePacket->nBits); INTERFACE.print(
"t");
748 for(
int i=0;i<10;i++){
749 INTERFACE.print(p->activePacket->buf[i],HEX); INTERFACE.print(
"t");
751 INTERFACE.println(
"");
753 for(
Register *p = DCCpp::progRegs.reg; p <= DCCpp::progRegs.maxLoadedReg;p++){
754 INTERFACE.print(
"P"); INTERFACE.print((
int)(p - DCCpp::progRegs.reg)); INTERFACE.print(
":t");
755 INTERFACE.print((
int)p); INTERFACE.print(
"t");
756 INTERFACE.print((
int)p->activePacket); INTERFACE.print(
"t");
757 INTERFACE.print(p->activePacket->nBits); INTERFACE.print(
"t");
758 for(
int i=0;i<10;i++){
759 INTERFACE.print(p->activePacket->buf[i],HEX); INTERFACE.print(
"t");
761 INTERFACE.println(
"");
763 INTERFACE.println(
"");
static float getCurrentMain()
static void parse(char *c)
static void parse(char *c)
static void parse(char *c)