/* maxlen 0 = read one text line */ I32 Perl_filter_read(pTHX_ int idx, SV *buf_sv, int maxlen) { filter_t funcp; SV *datasv = NULL; if (!PL_rsfp_filters) return -1; if (idx > AvFILLp(PL_rsfp_filters)) { /* Any more filters? */ /* Provide a default input filter to make life easy. */ /* Note that we append to the line. This is handy. */ DEBUG_P(PerlIO_printf(Perl_debug_log, "filter_read %d: from rsfp\n", idx)); if (maxlen) { /* Want a block */ int len ; const int old_len = SvCUR(buf_sv); /* ensure buf_sv is large enough */ SvGROW(buf_sv, (STRLEN)(old_len + maxlen)) ; if ((len = PerlIO_read(PL_rsfp, SvPVX(buf_sv) + old_len, maxlen)) <= 0){ if (PerlIO_error(PL_rsfp)) return -1; /* error */ else return 0 ; /* end of file */ } SvCUR_set(buf_sv, old_len + len) ; } else { /* Want a line */ if (sv_gets(buf_sv, PL_rsfp, SvCUR(buf_sv)) == NULL) { if (PerlIO_error(PL_rsfp)) return -1; /* error */ else return 0 ; /* end of file */ } } return SvCUR(buf_sv); } /* Skip this filter slot if filter has been deleted */ if ( (datasv = FILTER_DATA(idx)) == &PL_sv_undef) { DEBUG_P(PerlIO_printf(Perl_debug_log, "filter_read %d: skipped (filter deleted)\n", idx)); return FILTER_READ(idx+1, buf_sv, maxlen); /* recurse */ } /* Get function pointer hidden within datasv */ funcp = DPTR2FPTR(filter_t, IoANY(datasv)); DEBUG_P(PerlIO_printf(Perl_debug_log, "filter_read %d: via function %p (%s)\n", idx, datasv, SvPV_nolen_const(datasv))); /* Call function. The function is expected to */ /* call "FILTER_READ(idx+1, buf_sv)" first. */ /* Return: <0:error, =0:eof, >0:not eof */ return (*funcp)(aTHX_ idx, buf_sv, maxlen); }
boolean ModemGSM::SMSDequeue(EQueue pQueue, TSMSPtr pItem) { int idx; boolean res = false; DEBUG_P(PSTR("SMS Dequeue From --> ")); if(pQueue == qIn ) DEBUG_P(PSTR("IN"LB)); else DEBUG_P(PSTR("OUT"LB)); if(res = (pQueue == qIn ? FSMSInQueue.Dequeue(&idx) : FSMSOutQueue.Dequeue(&idx))) { if(pItem) if(!(res = ReadSMSAtIndex(idx, pItem))) DEBUG_P(PSTR("ReadSMSAtIndex FAIL"LB)); if(res) if(!(res = DeleteSMSAtIndex(idx))) DEBUG_P(PSTR("DeleteSMSAtIndex FAIL"LB)); } else DEBUG_P(PSTR("Dequeue FAIL"LB)); if(res) DEBUG_P(PSTR("SMS Dequeue OK"LB)); else DEBUG_P(PSTR("SMS Dequeue FAIL"LB)); return res; }
boolean ModemGSM::InnerSetup() { boolean res; FSMSResendPending = false; FSMSOutQueue.Clear(); FSMSInQueue.Clear(); FRegisteredToNetwork = false; FSignalLevel = UNKNOWN_LEVEL; FPBReady = false; FError = false; FKeepAliveFailedCount = 0; #ifdef REGISTRATION_DELAYED FNetworkRegDelayActive = false; #endif DiscardSerialInput(2000); //Discard serial line junk //Inizializziamo la seriale Hardware con il Baud rate imposto dal Modem GSM FSerial->end(); FSerial->begin(MODEM_SERIAL_BAUD_RATE); SendCommand(PSTR("AT+IPR=9600")); delay(500); FSerial->end(); FSerial->begin(9600); DiscardSerialInput(500); //discard the command ECHO (initialization will disable command echo) DEBUG_P(PSTR("Serial Speed 9600"LB)); FSerial->print(INIT_SEQUENCE); //Send initialization sequence to modem DiscardSerialInput(500); //discard the command ECHO (initialization will disable command echo) FSerial->print("\r"); //Commit res = WaitAnswer(1000, true) == saOk; DEBUG_P(PSTR("Init Command Sequence --> " INIT_SEQUENCE LB)); if(res) DEBUG_P(PSTR("OK"LB)); else DEBUG_P(PSTR("FAIL"LB)); return res; }
boolean ModemGSM::WriteSMS(const char *pDestPhoneNumber, const char *pBody,int *pIndex) { boolean res = false; DEBUG_P(PSTR("Writing SMS --> %s : "), pDestPhoneNumber); DEBUGLN(pBody); if(pIndex) *pIndex = 0; SendCommand(PSTR("AT+CMGW=\"%s\""), pDestPhoneNumber); DiscardPrompt(1500); //Discard modem prompt FSerial->print(pBody); delay(500); FSerial->print(0x1A,BYTE); //CTRL+Z End of Message for(;;) { //AT+CMGW can take a long time to answer switch(WaitAnswer(20000)) { case saOk: return res; case saError: case saTimeout: return false; case saUnknown: { int idx; if(sscanf_P(FRXBuff, PSTR("+CMGW: %d"), &idx) == 1) { DEBUG_P(PSTR("SMS Written at index -> %d"LB), idx); res = true; if(pIndex) *pIndex = idx; } else HandleURC(); } } } }
_X_EXPORT Bool VidModeGetNextModeline(int scrnIndex, pointer *mode, int *dotClock) { ScrnInfoPtr pScrn; VidModePtr pVidMode; DisplayModePtr p; DEBUG_P("VidModeGetNextModeline"); if (!VidModeAvailable(scrnIndex)) return FALSE; pScrn = xf86Screens[scrnIndex]; pVidMode = VMPTR(pScrn->pScreen); for (p = pVidMode->Next; p != NULL && p != pVidMode->First; p = p->next) { if (p->status == MODE_OK) { pVidMode->Next = p->next; *mode = (pointer)p; *dotClock = VidModeGetDotClock(scrnIndex, p->Clock); return TRUE; } } return FALSE; }
int Perl_runops_debug(pTHX) { #ifdef DEBUGGING if (!PL_op) { if (ckWARN_d(WARN_DEBUGGING)) Perl_warner(aTHX_ WARN_DEBUGGING, "NULL OP IN RUN"); return 0; } do { PERL_ASYNC_CHECK(); if (PL_debug) { if (PL_watchaddr != 0 && *PL_watchaddr != PL_watchok) PerlIO_printf(Perl_debug_log, "WARNING: %"UVxf" changed from %"UVxf" to %"UVxf"\n", PTR2UV(PL_watchaddr), PTR2UV(PL_watchok), PTR2UV(*PL_watchaddr)); DEBUG_s(debstack()); DEBUG_t(debop(PL_op)); DEBUG_P(debprof(PL_op)); } } while ((PL_op = CALL_FPTR(PL_op->op_ppaddr)(aTHX))); TAINT_NOT; return 0; #else return runops_standard(); #endif /* DEBUGGING */ }
boolean ModemGSM::ReadSMSAtIndex(int pIndex, TSMSPtr pSMS) { boolean hasEntry = false; DEBUG_P(PSTR("Reading SMS entry at --> %d"LB), pIndex); SendCommand(PSTR("AT+CMGR=%d"), pIndex); for(;;) { switch(WaitAnswer(5000)) { case saOk: return hasEntry; case saError: case saTimeout: return false; case saUnknown: { int idx; if(sscanf_P(FRXBuff, PSTR("+CMGR: \"%*[^\"]\",\"%20[^\"]\""), pSMS->phone) == 1) { DEBUG_P(PSTR(" SMS Number -> %s"LB), pSMS->phone); if(Readln(500, true) != 0) { DEBUG_P(PSTR(" SMS Text -> ")); DEBUGLN(FRXBuff); strncpy(pSMS->body, FRXBuff, sizeof(pSMS->body) - 1); pSMS->body[sizeof(pSMS->body) - 1] = '\0'; hasEntry = true; } else { DEBUG_P(PSTR("** Timeout reading SMS text"LB)); return false; } } else HandleURC(); } } } }
boolean ModemGSM::DeletePBEntryAtIndex(byte pIndex) { DEBUG_P(PSTR("Deleting PB entry at --> %d"LB), pIndex); SendCommand(PSTR("AT+CPBW=%d"), (int) pIndex); return WaitAnswer(1000, true) == saOk; }
boolean ModemGSM::SendSMS(const char *pDestPhoneNumber, const char *pBody) { boolean res = false; int idx; if(res = WriteSMS(pDestPhoneNumber, pBody, &idx)) { res = FSMSOutQueue.Enqueue(idx); if(res) { DEBUG_P(PSTR("SMS Enqueue OK index --> %d"LB), idx); } else DEBUG_P(PSTR("SMS Enqueue FAIL"LB)); } return res; }
boolean ModemGSM::ClearSMSMemory() { DEBUG_P(PSTR("Deleting All SMS from SM Memory"LB)); SendCommand(PSTR("AT+CMGD=0,4")); boolean res = WaitAnswer(20000, true) == saOk; delay(2000); return res; }
boolean ModemGSM::DeleteSMSAtIndex(int pIndex) { boolean res = false; DEBUG_P(PSTR("Deleting SMS entry at --> %d"LB), pIndex); SendCommand(PSTR("AT+CMGD=%d"), pIndex); return WaitAnswer(10000, true) == saOk; }
boolean ModemGSM::SendKeepAlive() { boolean res = false; DEBUG_P(PSTR("Sending KeepAlive"LB)); SendCommand(PSTR("AT")); return WaitAnswer(1000, true) == saOk; }
boolean SMSIndexQueue<i>::Enqueue(int pIndex) { if(FCount >= i) { DEBUG_P(PSTR("SMS Queue is Full"LB)); return false; } FSMSQueue[FCount] = pIndex; FCount++; };
boolean ModemGSM::SendSMSAtIndex(int pIndex) { boolean res = false; DEBUG_P(PSTR("Sending SMS at index --> %d"LB), pIndex); #if SIMULATION delay(5000); if(1 || (FSMSResendPending && (FSMSRetry==10))) { FURCQueue.Enqueue("+CMSS: 99"); res = true; } else FURCQueue.Enqueue("ERROR"); #else SendCommand(PSTR("AT+CMSS=%d"), pIndex); for(;;) { switch(WaitAnswer(45000, true)) { case saOk: { DEBUG_P(PSTR(" SMS sent"LB)); return true; } case saError: case saTimeout: return false; } } #endif return res; }
_X_EXPORT Bool VidModeExtensionInit(ScreenPtr pScreen) { #ifdef XF86VIDMODE VidModePtr pVidMode; DEBUG_P("VidModeExtensionInit"); if (!xf86GetVidModeEnabled()) { DEBUG_P("!xf86GetVidModeEnabled()"); return FALSE; } if (serverGeneration != VidModeGeneration) { if ((VidModeIndex = AllocateScreenPrivateIndex()) < 0) { DEBUG_P("AllocateScreenPrivateIndex() failed"); return FALSE; } VidModeGeneration = serverGeneration; } if (!(pScreen->devPrivates[VidModeIndex].ptr = xcalloc(sizeof(VidModeRec), 1))) { DEBUG_P("xcalloc failed"); return FALSE; } pVidMode = VMPTR(pScreen); pVidMode->Flags = 0; pVidMode->Next = NULL; pVidMode->CloseScreen = pScreen->CloseScreen; pScreen->CloseScreen = VidModeClose; VidModeCount++; return TRUE; #else DEBUG_P("no vidmode extension"); return FALSE; #endif }
_X_EXPORT Bool VidModeDeleteModeline(int scrnIndex, pointer mode) { ScrnInfoPtr pScrn; DEBUG_P("VidModeDeleteModeline"); if ((mode == NULL) || (!VidModeAvailable(scrnIndex))) return FALSE; pScrn = xf86Screens[scrnIndex]; xf86DeleteMode(&(pScrn->modes), (DisplayModePtr)mode); return TRUE; }
_X_EXPORT Bool VidModeZoomViewport(int scrnIndex, int zoom) { ScrnInfoPtr pScrn; DEBUG_P("VidModeZoomViewPort"); if (!VidModeAvailable(scrnIndex)) return FALSE; pScrn = xf86Screens[scrnIndex]; xf86ZoomViewport(pScrn->pScreen, zoom); return TRUE; }
void APP_vReactivatePreviousApp(void) { DEBUG_P(PSTR("APP_vReactivatePreviousApp()\n")); if (ptdApp->ucStackTopNext==0) { RESET_P(PSTR("AppReaStEmp")); return; } APP_vRouteEvent(APP_LOST_CONTROL); ptdApp->ucStackTopNext--; APP_vRouteEvent(APP_REACTIVATED); }
_X_EXPORT ModeStatus VidModeCheckModeForDriver(int scrnIndex, pointer mode) { ScrnInfoPtr pScrn; DEBUG_P("VidModeCheckModeForDriver"); if ((mode == NULL) || (!VidModeAvailable(scrnIndex))) return MODE_ERROR; pScrn = xf86Screens[scrnIndex]; return xf86CheckModeForDriver(pScrn, (DisplayModePtr)mode, 0); }
_X_EXPORT Bool VidModeGetViewPort(int scrnIndex, int *x, int *y) { ScrnInfoPtr pScrn; DEBUG_P("VidModeGetViewPort"); if (!VidModeAvailable(scrnIndex)) return FALSE; pScrn = xf86Screens[scrnIndex]; *x = pScrn->frameX0; *y = pScrn->frameY0; return TRUE; }
_X_EXPORT Bool VidModeGetMonitor(int scrnIndex, pointer *monitor) { ScrnInfoPtr pScrn; DEBUG_P("VidModeGetMonitor"); if (!VidModeAvailable(scrnIndex)) return FALSE; pScrn = xf86Screens[scrnIndex]; *monitor = (pointer)(pScrn->monitor); return TRUE; }
boolean SMSIndexQueue<i>::Peek(int *pIndex) { if(FCount == 0) { DEBUG_P(PSTR("** Peek: SMS Queue is Empty"LB)); return false; } if(pIndex) { *pIndex = FSMSQueue[0]; } return true; };
_X_EXPORT Bool VidModeGetCurrentModeline(int scrnIndex, pointer *mode, int *dotClock) { ScrnInfoPtr pScrn; DEBUG_P("VidModeGetCurrentModeline"); if (!VidModeAvailable(scrnIndex)) return FALSE; pScrn = xf86Screens[scrnIndex]; *mode = (pointer)(pScrn->currentMode); *dotClock = pScrn->currentMode->Clock; return TRUE; }
_X_EXPORT Bool VidModeGetGamma(int scrnIndex, float *red, float *green, float *blue) { ScrnInfoPtr pScrn; DEBUG_P("VidModeGetGamma"); if (!VidModeAvailable(scrnIndex)) return FALSE; pScrn = xf86Screens[scrnIndex]; *red = pScrn->gamma.red; *green = pScrn->gamma.green; *blue = pScrn->gamma.blue; return TRUE; }
_X_EXPORT int VidModeGetDotClock(int scrnIndex, int Clock) { ScrnInfoPtr pScrn; DEBUG_P("VidModeGetDotClock"); if (!VidModeAvailable(scrnIndex)) return 0; pScrn = xf86Screens[scrnIndex]; if ((pScrn->progClock) || (Clock >= MAXCLOCKS)) return Clock; else return pScrn->clock[Clock]; }
/** * Main status screen */ void DISP_vPrintStatusScreen(void) { DEBUG_P(PSTR("DISP_vPrintStatusScreen\n")); if (bShowScreenTitle) { vDisplayScreenTitle(); bShowScreenTitle = FALSE; } LCD_vClrScr(); switch (eCurrentScreenId) { case STATUS_SCREEN_IDLE: DISP_STOP_BLINK_TIMER LCD_vPuts_P(PSTR("Z ")); vPrintTemp(ONEWIRE_ZASO_IDX); if (atdKnownTempSensors[ONEWIRE_ZASO_IDX].iTempInt < pstSettings->ucMinTempZasobnik) { DISP_START_BLINK_TIMER if (bBlinkState==TRUE) { LCD_vGotoXY(2,0); LCD_vPutc(255); // Put character '#' LCD_vPutc(255); // Put character '#' LCD_vPutc(255); // Put character '#' LCD_vPutc(255); // Put character '#' } } LCD_vGotoXY(9,0); LCD_vPuts_P(PSTR("K ")); vPrintTemp(ONEWIRE_KRAN_IDX); #if 0 if (atdKnownTempSensors[ONEWIRE_KRAN_IDX].iTempInt < pstSettings->ucMinTempKran) { DISP_START_BLINK_TIMER if (bBlinkState==TRUE) { LCD_vGotoXY(11,0); LCD_vPutc(255); // Put character '#' LCD_vPutc(255); // Put character '#' LCD_vPutc(255); // Put character '#' LCD_vPutc(255); // Put character '#' } }
_X_EXPORT int VidModeGetNumOfModes(int scrnIndex) { pointer mode = NULL; int dotClock= 0, nummodes = 0; DEBUG_P("VidModeGetNumOfModes"); if (!VidModeGetFirstModeline(scrnIndex, &mode, &dotClock)) return nummodes; do { nummodes++; if (!VidModeGetNextModeline(scrnIndex, &mode, &dotClock)) return nummodes; } while (TRUE); }
static void vDisplayScreenTitle(void) { DEBUG_P(PSTR("vDisplayScreenTitle\n")); switch (eCurrentScreenId) { case STATUS_SCREEN_IDLE: // no title to show, return immediately return; break; default: break; } LCD_vClrScr (); switch (eCurrentScreenId) { default: return; break; case STATUS_SCREEN_NEW_SENSORS: LCD_vPuts_P (PSTR("Nowe sensory:")); break; case STATUS_SCREEN_KNOWN_SENSORS: LCD_vPuts_P (PSTR("Zapisane sens.:")); break; case STATUS_SCREEN_TEMP: LCD_vPuts_P (PSTR("Temp:")); break; case STATUS_SCREEN_DCF: LCD_vPuts_P (PSTR("DCF77:")); break; } //TODO - it is not beautiful.... // forcing immediately display update //DISP_REFRESH LCD_Draw(); LCD_DrawDebug(); breakable_delay_ms(300); }
_X_EXPORT Bool VidModeLockZoom(int scrnIndex, Bool lock) { ScrnInfoPtr pScrn; DEBUG_P("VidModeLockZoom"); if (!VidModeAvailable(scrnIndex)) return FALSE; pScrn = xf86Screens[scrnIndex]; if (xf86Info.dontZoom) return FALSE; xf86LockZoom(pScrn->pScreen, lock); return TRUE; }
/** * Set activated application as current and call handler with event @ref APP_ACTIVATE * @param eNewActiveAppId */ void APP_vActivateApp(APP_ID_DEF eNewActiveAppId) { DEBUG_P(PSTR("APP_vActivateApp(%d)\n"), eNewActiveAppId); if (ptdApp->ucStackTopNext >= APP_STACK_DEPTH) { RESET_P(PSTR("AppStackFull")); return; } if (ptdApp->ucStackTopNext > 0) { APP_vRouteEvent(APP_LOST_CONTROL); } ptdApp->aeAppStack[ptdApp->ucStackTopNext] = eNewActiveAppId; ptdApp->ucStackTopNext++; APP_vRouteEvent(APP_ACTIVATED); }