void MenloWiFiArduino::Stop() { ResetWatchdog(); // Tell watchdog we are still alive DBG_PRINT("ArduinoWiFi Stop"); m_wifi->stop(); ResetWatchdog(); // Tell watchdog we are still alive }
void SafeTransitExecute3(void) { uint i; uchar j; if (bInBuff5 >= bPORTS) Result(bRES_BADADDRESS); else if (IsSlave(bInBuff5)) Result(bRES_BADPORT); else if (IndexInBuff() <= 10) Result(bRES_BADDATA); else { SaveInBuff(); iwInBuffSave = IndexInBuff(); j = ibPort; ibPort = bInBuff5; cbHeaderBcc = bInBuff8; cwInBuffBcc = 0; InitPush(0); for (i=0; i<iwInBuffSave-11; i++) PushChar(mpbInBuffSave[i+9]); Query(bInBuff6+bInBuff7*0x100, iwInBuffSave-11, 1); InitWaitAnswer(); while (1) { if (fKey == true) { mpSerial[ibPort] = SER_BADLINK; break; } ResetWatchdog(); ShowWaitAnswer(1); if (GetWaitAnswer()) { mpSerial[ibPort] = SER_BADLINK; break; } if (mpSerial[ibPort] == SER_INPUT_MASTER) DecompressK(0); if (mpSerial[ibPort] == SER_POSTINPUT_MASTER) break; else if ((mpSerial[ibPort] == SER_OVERFLOW) || (mpSerial[ibPort] == SER_BADLINK)) break; } MonitorIn(); SaveInBuff(); iwInBuffSave = IndexInBuff(); mpSerial[ibPort] = SER_BEGIN; ibPort = j; InitPushCRC(); if (iwInBuffSave > 0) for (i=0; i<iwInBuffSave; i++) PushChar(mpbInBuffSave[i]); Output(iwInBuffSave); } }
serial InputS(void) { InputStart(); InitWaitAnswer(); while (1) { if (fKey == true) { mpSerial[ibPort] = SER_BADLINK; break; } ResetWatchdog(); ShowWaitAnswer(1); if (GetWaitAnswer()) { mpSerial[ibPort] = SER_BADLINK; break; } if (mpSerial[ibPort] == SER_INPUT_MASTER) DecompressS(); if (mpSerial[ibPort] == SER_POSTINPUT_MASTER) { if (ChecksumS() == 0) { InputGoodCheck(); mpSerial[ibPort] = SER_GOODCHECK; } else mpSerial[ibPort] = SER_BADCHECK; break; } else if ((mpSerial[ibPort] == SER_OVERFLOW) || (mpSerial[ibPort] == SER_BADLINK)) break; } return mpSerial[ibPort]; }
void SafeTransitExecute2(void) { uint i; uchar j; if (bInBuff5 >= bPORTS) Result(bRES_BADADDRESS); else if (IsSlave(bInBuff5)) Result(bRES_BADPORT); else if (IndexInBuff() <= 10) Result(bRES_BADDATA); else { SaveInBuff(); iwInBuffSave = IndexInBuff(); j = ibPort; ibPort = bInBuff5; InitPush(0); for (i=0; i<iwInBuffSave-10; i++) PushChar(mpbInBuffSave[i+8]); Query(bInBuff6+bInBuff7*0x100, iwInBuffSave-10, 1); InitWaitAnswer(); while (1) { if (fKey == true) { mpSerial[ibPort] = SER_BADLINK; break; } ResetWatchdog(); ShowWaitAnswer(1); if (GetWaitAnswer()) { mpSerial[ibPort] = SER_BADLINK; break; } if (mpSerial[ibPort] == SER_POSTINPUT_MASTER) break; else if ((mpSerial[ibPort] == SER_OVERFLOW) || (mpSerial[ibPort] == SER_BADLINK)) break; } if (mpSerial[ibPort] != SER_POSTINPUT_MASTER) { ibPort = j; Result(bRES_BADMODE); } else { mpSerial[ibPort] = SER_BADLINK; // !!! SaveInBuff(); iwInBuffSave = IndexInBuff(); ibPort = j; InitPushCRC(); for (i=0; i<iwInBuffSave; i++) PushChar(mpbInBuffSave[i]); Output(iwInBuffSave); } } }
void ShowFlashRead(void) { ResetWatchdog(); ShowPercent((ulong)100*(++wPage)/(FLASH_END-FLASH_BEGIN+1)); #ifdef NO_DISPLAY RunLED_Reset(); #endif }
void ShowFlashErase(void) { ResetWatchdog(); ShowPercent((ulong)100*(++wPage)/(IMPHOUCAN_PAGES + bMINUTES + bDAYS*2 + bMONTHS*3 + PARAMS_PAGES*wTIMES + bRECORD_PAGES*6 + wRECORD2_PAGES*1)); #ifdef NO_DISPLAY RunLED_Reset(); #endif }
serial Input31(void) { InputStart(); InitWaitAnswer(); while (1) { if (fKey == true) { mpSerial[ibPort] = SER_BADLINK; break; } ResetWatchdog(); ShowWaitAnswer(1); if (GetWaitAnswer()) { mpSerial[ibPort] = SER_BADLINK; break; } if (mpSerial[ibPort] == SER_INPUT_MASTER) { if ((InBuff(0) == 0x7E) && (IndexInBuff() > 3) && (IndexInBuff() == InBuff(1)+4)) mpSerial[ibPort] = SER_BADLINK; } if (mpSerial[ibPort] == SER_POSTINPUT_MASTER) { uchar bCrc = MakeCrc8Bit31InBuff(1, CountInBuff()-1); if (bCrc == 0) { Unpack31(); InputGoodCheck(); mpSerial[ibPort] = SER_GOODCHECK; } else mpSerial[ibPort] = SER_BADCHECK; break; } else if (mpSerial[ibPort] == SER_BADLINK) { uchar bCrc = MakeCrc8Bit31InBuff(1, IndexInBuff()-1); if (bCrc == 0) { Unpack31(); InputGoodCheck(); mpSerial[ibPort] = SER_GOODCHECK; } else mpSerial[ibPort] = SER_BADCHECK; break; } else if (mpSerial[ibPort] == SER_OVERFLOW) break; } MonitorIn(); return mpSerial[ibPort]; }
void MenloWiFiArduino::PrintDiagnostics(Stream* stream) { IPAddress ip; long rssi; // // WiFi is a global statically created class // when the WiFi library is included. // // uint8_t* WiFi.macAddress(uint8_t* mac); ResetWatchdog(); // Tell watchdog we are still alive stream->print(F("SSID: ")); stream->println(WiFi.SSID()); ip = WiFi.localIP(); stream->print(F("IP Address: ")); stream->println(ip); ip = WiFi.gatewayIP(); stream->print(F("Gateway IP Address: ")); stream->println(ip); ResetWatchdog(); // Tell watchdog we are still alive ip = WiFi.subnetMask(); stream->print(F("SubNet Mask: ")); stream->println(ip); rssi = WiFi.RSSI(); stream->print(F("RSSI: ")); stream->print(rssi); stream->println(F(" dBm")); ResetWatchdog(); // Tell watchdog we are still alive }
void GetDefGrpDayUni(void) { uchar i,j,k; if ((bInBuff6 != 0) || (bInBuff8 != 0) || (bInBuffA != 0) || (bInBuffC != 0)) Result2_Info(bUNI_BADDATA, 1); else if ((bInBuff9 == 0) || (bInBuffD == 0)) Result2_Info(bUNI_BADDATA, 2); else if (bInBuff7 > bGROUPS) Result2_Info(bUNI_BADDATA, 3); else if (bInBuff7+bInBuff9-1 > bGROUPS) Result2_Info(bUNI_BADDATA, 4); else if (bInBuffB >= wHOURS/48) Result2_Info(bUNI_BADDATA, 5); else if (bInBuffB + bInBuffD >= wHOURS/48) Result2_Info(bUNI_BADDATA, 6); else { InitPushUni(); k = (((bInBuff9-1) / 16)+1)*2; for (j=bInBuffB; j<bInBuffB+bInBuffD; j++) { ResetWatchdog(); memset(&mpbDefUni, 0, sizeof(mpbDefUni)); uint iwHhr = GetDayHhrIndex(j); for (i=0; i<48; i++) { LoadImpHouFree(iwHhr); uchar g; for (g=bInBuff7; g<bInBuff7+bInBuff9; g++) { if (GetDefGrp(g-1) == 1) mpbDefUni[k-1 - ((g - bInBuff7) / 8)] |= (uchar)(0x01 << ((g - bInBuff7) % 8)); } if (++iwHhr >= wHOURS) iwHhr = 0; } Push(mpbDefUni, k); } ulong dw = DateToDayIndex(*GetCurrTimeDate()); dw -= bInBuffB; time ti = DayIndexToDate(dw); Output2_Code((uint)k*bInBuffD, 0, ti); } }
/* the clearing of the flags cannot be done in the idle loop because * it may be interrupted */ void TaskCheckIn(etTaskCheckInId TaskId) { static unsigned char TaskCheckInFlags = 0; portENTER_CRITICAL(); TaskCheckInFlags |= (1 << TaskId); if (TaskCheckInFlags == ALL_TASKS_HAVE_CHECKED_IN) { /* all tasks have checked in - so the flags can be cleared * and the watchdog can be kicked */ TaskCheckInFlags = 0; ResetWatchdog(); } portEXIT_CRITICAL(); }
static void ModifyTimeHandler(tMessage* pMsg) { switch (pMsg->Options) { case MODIFY_TIME_INCREMENT_HOUR: RTCHOUR = (RTCHOUR == 23) ? 0 : RTCHOUR + 1; break; case MODIFY_TIME_INCREMENT_MINUTE: RTCMIN = (RTCMIN == 59) ? 0 : RTCMIN + 1; break; case MODIFY_TIME_INCREMENT_DOW: RTCDOW = (RTCDOW == 6) ? 0 : RTCDOW + 1; break; } ResetWatchdog(); // UpdateClockWidget(MSG_OPT_NONE); }
bool ReadDataQ(void) { uchar j; sprintf(szLo," %02u %02u.%02u.%02u", tiDig.bHour, tiDig.bDay,tiDig.bMonth,tiDig.bYear); if (SearchDefHouIndex(tiDig) == 0) return(1); if ((tiDig.bDay == tiCurr.bDay) && (tiDig.bMonth == tiCurr.bMonth) && (tiDig.bYear == tiCurr.bYear)) j = 47-(tiCurr.bHour*2+tiCurr.bMinute/30); else j = 0; uchar h; for (h=j; h<48; h++) { ResetWatchdog(); MakeDataQ(47-h); MakeSpecial(tiDig); if (MakeStopHou(0) == 0) return(0); ulong dw = DateToHouIndex(tiDigPrev); dw -= wBaseCurr; tiDig = HouIndexToDate(dw); iwDigHou = (wHOURS+iwDigHou-1)%wHOURS; } return(1); }
static void ModifyTimeHandler(tMessage* pMsg) { IncRtc(pMsg->Options); DrawDateTime(); ResetWatchdog(); //battery timer can't be fire }
int MenloWiFiArduino::Read() { ResetWatchdog(); // Tell watchdog we are still alive return m_wifi->read(); }
bool ResetNvram(void) { uint i; ShowHi(szMemoryTest1); for (i=0; i<=dwNVRAM_BYTES/1000; i++) { ResetWatchdog(); if (Test1WriteNvramBuff(i*1000, 1000) == false) return false; if (Test1ReadNvramBuff(i*1000, 1000) == false) return false; ShowPercent(0 + (uint)20*i/(dwNVRAM_BYTES/1000)); #ifdef NO_DISPLAY RunLED_Reset(); #endif } for (i=0; i<=dwNVRAM_BYTES/1000; i++) { ResetWatchdog(); if (Test2WriteNvramBuff(i*1000, 1000, 0x55) == false) return false; if (Test2ReadNvramBuff(i*1000, 1000, 0x55) == false) return false; ShowPercent(20 + (uint)20*i/(dwNVRAM_BYTES/1000)); #ifdef NO_DISPLAY RunLED_Reset(); #endif } for (i=0; i<=dwNVRAM_BYTES/1000; i++) { ResetWatchdog(); if (Test2WriteNvramBuff(i*1000, 1000, 0xAA) == false) return false; if (Test2ReadNvramBuff(i*1000, 1000, 0xAA) == false) return false; ShowPercent(40 + (uint)20*i/(dwNVRAM_BYTES/1000)); #ifdef NO_DISPLAY RunLED_Reset(); #endif } for (i=0; i<=dwNVRAM_BYTES/1000; i++) { ResetWatchdog(); if (Test2WriteNvramBuff(i*1000, 1000, 0xFF) == false) return false; if (Test2ReadNvramBuff(i*1000, 1000, 0xFF) == false) return false; ShowPercent(60 + (uint)20*i/(dwNVRAM_BYTES/1000)); #ifdef NO_DISPLAY RunLED_Reset(); #endif } for (i=0; i<=dwNVRAM_BYTES/1000; i++) { ResetWatchdog(); if (Test2WriteNvramBuff(i*1000, 1000, 0x00) == false) return false; if (Test2ReadNvramBuff(i*1000, 1000, 0x00) == false) return false; ShowPercent(80 + (uint)20*i/(dwNVRAM_BYTES/1000)); #ifdef NO_DISPLAY RunLED_Reset(); #endif } return true; }
int MenloWiFiArduino::Read(uint8_t* buf, size_t size) { ResetWatchdog(); // Tell watchdog we are still alive return m_wifi->read(buf, size); }
size_t MenloWiFiArduino::Write(uint8_t c) { ResetWatchdog(); // Tell watchdog we are still alive return m_wifi->write(c); }
size_t MenloWiFiArduino::Write(const uint8_t* buf, size_t size) { ResetWatchdog(); // Tell watchdog we are still alive return m_wifi->write(buf, size); }
void InitializeWatchdog(void){ WatchdogRunning = 1; VelCtrlRunning = 0; VelCtrlRate = 20; ResetWatchdog(); }
void MenloWiFiArduino::Flush() { ResetWatchdog(); // Tell watchdog we are still alive return m_wifi->flush(); }
void handleCommMessage(void){ char buffer[COMM_BUFFER_SIZE]; unsigned char function_code = 0; long i; buffer[64]=0; buffer[79]=0; UARTgets((uint8*)buffer, COMM_BUFFER_SIZE); //UARTgetMessage(buffer); //UARTprintf("MESSAGE GET!!%s\r\n", buffer); if(isValidMessage(buffer)) { for(i = 0; i < CODE_LENGTH; i++) //generate hash of function code { function_code ^= buffer[CODE_START + i]; } switch(function_code) { case SPLM: //JoystickXOut(SATURATE(atoi(&buffer[DATA_START]),0,255)); //UARTprintf("GOOD MESSAGE- SVXA: %s\r\n", buffer); SetLeftMotor(SATURATE(atoi(&buffer[DATA_START]),-128,127)); VelCtrlRunning = 0; ResetWatchdog(); //we got a valid message, so they are still talking to us break; case SPRM: //JoystickYOut(SATURATE(atoi(&buffer[DATA_START]),0,255)); //UARTprintf("GOOD MESSAGE- SVYA: %s\r\n", buffer); SetRightMotor(SATURATE(atoi(&buffer[DATA_START]),-128,127)); VelCtrlRunning = 0; ResetWatchdog(); //we got a valid message, so they are still talking to us break; case SAHS: SetHokuyoServo(SATURATE(atoi(&buffer[DATA_START]),-128,127)); break; case SVLX: UpdateLinearX(atoi(&buffer[DATA_START])); ResetWatchdog(); VelCtrlRunning = 1; break; case SVAZ: UpdateAngularZ(atoi(&buffer[DATA_START])); VelCtrlRunning = 1; ResetWatchdog(); break; case ETFM: EnableSensorFeedbackMessages = 1; break; case DTFM: EnableSensorFeedbackMessages = 0; break; case RSTE: ResetEncoders(); break; case STMR: if(1000 % atoi(&buffer[DATA_START]) == 0) SetMessageRate(atoi(&buffer[DATA_START])); else UARTprintf("INVALID MESSAGE RATE (1000%rate must = 0): %s", buffer); break; case SETT: SetTime(atoi(&buffer[DATA_START])); break; case EHST: EnableHokuyoTilting(); break; case DHST: DisableHokuyoTilting(); break; case SHTR: if(1000 % atoi(&buffer[DATA_START]) == 0) SetHokuyoTiltRate(atoi(&buffer[DATA_START])); else UARTprintf("INVALID RATE (1000%rate must = 0): %s", buffer); break; case SACD: SetAccelDivisor(atoi(&buffer[DATA_START])); break; /*case FLPC: Servo_0_WriteCompare1(atoi(&buffer[DATA_START])); break; case FRPC: Servo_0_WriteCompare2(atoi(&buffer[DATA_START])); break;*/ default: UARTprintf("UNRECOGNIZED MESSAGE: %s\r\n", buffer); break; } } else { UARTprintf("INVALID START CHARACTER: %s\r\n", buffer); } }
// // Attempt to connect // void MenloWiFiArduino::OnConnect() { int status; RDBG_PRINT("ArduinoWiFi OnConnect"); if (m_ssid[0] == '\0') { SetConnectionTargetState(WiFiConnectionStateNoCredentials); return; } MenloDebug::PrintNoNewline(F("WiFi Attempt conn to ")); MenloDebug::Print(m_ssid); PrintMacAddress(); ResetWatchdog(); // A NULL Password is ok if (m_password[0] == '\0') { MenloDebug::Print(F(" with no password")); status = WiFi.begin(m_ssid); } else { MenloDebug::PrintNoNewline(F(" with ")); MenloDebug::Print(m_password); status = WiFi.begin(m_ssid, m_password); } ResetWatchdog(); if (status == WL_CONNECTED) { MenloDebug::PrintNoNewline(F("WiFi Connected with ")); MenloDebug::Print(m_ssid); // Connected SetConnectionTargetState(WiFiConnectionStateConnected); return; } if (status == WL_IDLE_STATUS) { xDBG_PRINT("WL_IDLE_STATUS"); // // This gets signaled while the board is syncing with the // network. We need to attempt a retry again it before // moving onto any new SSID or password, otherwise it will // the sign on sequence. // // stay in the WiFiStatusConnecting state // fallthrough; } else { MenloDebug::PrintNoNewline(F("WiFi Connect Error Status ")); MenloDebug::PrintHex(status); // stay in the WiFiStatusConnecting state PrintMacAddress(); // fallthrough; } // // All Arduino example code for WiFi has a 10 second delay // after each connection attempt. // // Note: This should be done as part of the state machine and // timer. // SetConnectingWait(10 * 1000); }