int main(int argc, char **argv)
{
  signal(SIGINT, signal_handler);
  if (argc != 2)
    usage();
  const char *serial_device = argv[1];
  LightweightSerial *port = new LightweightSerial(serial_device, 1000000);
  perish_if(!port, "Could't open the specified serial port");
  uint8_t b = 0;
  while (port->is_ok() && !g_done)
  {
    if (port->read(&b))
    {
      putc(b, stdout);
      fflush(stdout);
    }
    else
      usleep(1000);
  }
  return 0;
}
Beispiel #2
0
	void readLine(char * buffer)
	{
		char read;
		stringstream ss;	
		LightweightSerial serial = LightweightSerial(PATH,BAUD);

		while(read != '#')
		{
			read = ' ';
			serial.read(&read);	

			if(read != ' ' && read !='\r')
			{
				ss << read;		
				if(read == '#')
				{
						ROS_DEBUG_NAMED("Serial","READ: %s",ss.str().c_str());
				}
			}
		}
		sprintf(buffer,"%s",ss.str().c_str());
	}