Ejemplo n.º 1
0
Archivo: main.c Proyecto: bpg/RFBee
static void loop() {
	if (serial_available() > 0) {
#ifdef DEBUG
		printf("Sdat\r\n");
#endif
		sleepCounter = 1000; // reset the sleep counter
		if (serialMode == SERIALCMDMODE) {
			readSerialCmd();
		} else {
			readSerialData();
		}
	}

	if (GDO_PIN & GDO0) {
#ifdef DEBUG
		printf("Rdat\r\n");
#endif
		writeSerialData();
		sleepCounter++; // delay sleep
	}

	sleepCounter--;

	// check if we can go to sleep again, going into low power too early will result in lost data in the CCx fifo.
	if ((sleepCounter == 0)
			&& (config_get(CONFIG_RFBEE_MODE) == LOWPOWER_MODE)) {
#ifdef DEBUG
		printf("low power on\r\n");
#endif
		lowPowerOn();
#ifdef DEBUG
		printf("woke up\r\n");
#endif
	}
}
Ejemplo n.º 2
0
bool T_TX_InterfaceSerial::getInputData (TSimInputs *inputs)/*{{{*/
{
  // Read serial data and update rawData[]
  readSerialData ();

  CalibMixMapValues(inputs, rawData);
  return true;
}
Ejemplo n.º 3
0
int main(int argc, char **argv)
{
    char	deviceFilePath[MAXPATHLEN];
    int		fileDescriptor;
    int		c;
    int		bCont;	// flag for continuous operation
    struct sigaction act;

    opterr = 0;
    while ((c=getopt(argc, argv, "cd:h")) != -1) {
	switch (c) {
	    case 'c': bCont = 1; break;
	    case 'd': strcpy(deviceFilePath, optarg); break;
	    case 'h': printHelp(); return 1;
	    case '?': if (optopt=='d')
			fprintf(stderr, "Option -%c requires an argument.\n", optopt);
		      else if (isprint (optopt))
			fprintf(stderr, "Unknown option '-%c'.\n", optopt);
		      else
			fprintf(stderr, "Unknown option character '\\x%x'.\n", optopt);
		      return 1;
	    default: abort();
	}
    }

    act.sa_handler = intHandler;
    sigaction(SIGINT, &act, NULL);	// catch Ctrl-C

//printf ("dev: %s\n", deviceFilePath);

    if (!deviceFilePath[0])
    {
        printf("No serial device found. Did you specify the '-d /dev/device' option?\n");
        return EX_UNAVAILABLE;
    }

    fileDescriptor = openSerialPort(deviceFilePath);
    if (fileDescriptor == -1)
    {
        return EX_IOERR;
    }

    if (!(readSerialData(fileDescriptor, bCont))) {
        printf("Could not read data.\n");
    }

    closeSerialPort(fileDescriptor);
//    printf("Modem port closed.\n");
    return EX_OK;
}
Ejemplo n.º 4
0
void T_TX_InterfaceSerial::getRawData (float *dest)/*{{{*/
{
  // Read serial data and update rawData[]
  readSerialData ();

  int numAxes=getNumAxes ();
  if (numAxes > TX_MAXAXIS)
  {
    numAxes = TX_MAXAXIS;
  }
  for (int i = 0; i < numAxes; ++i)
  {
    *(dest + i) = rawData[i];
  }
}
Ejemplo n.º 5
0
void at
(
    char const * com,
    int tdelay,
    bool readsw
)
{
    _swser.println( com );
    delay( tdelay );

    if( readsw )
    {
        readSerialData( );
#if CFG_DEBUG == true
        SIM900::printSerialData( );
#endif
    }

}