• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ cfsetspeed函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中cfsetspeed函数的典型用法代码示例。如果您正苦于以下问题:C++ cfsetspeed函数的具体用法?C++ cfsetspeed怎么用?C++ cfsetspeed使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了cfsetspeed函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: serial_set_rate

int serial_set_rate(int fd, int baudrate, int hwflow)
{
	struct termios term;
	int ret;

	ret = tcgetattr(fd, &term);
	if (ret < 0)
		goto err;

	cfmakeraw(&term);
	cfsetspeed(&term, get_rate_const(baudrate));

	if (hwflow)
		term.c_cflag |= CRTSCTS;
	else
		term.c_cflag &= ~CRTSCTS;

	ret = tcsetattr(fd, TCSAFLUSH, &term);
	if (ret < 0)
		goto err;

	return 0;
 err:
	perror("unable to configure serial port");
	return ret;
}
开发者ID:n7nix,项目名称:dantracker,代码行数:26,代码来源:serial.c


示例2: open

  bool open(const string& portname, unsigned rate, bool flowcontrol) {
    close();

    port = ::open(portname, O_RDWR | O_NOCTTY | O_NDELAY | O_NONBLOCK);
    if(port == -1) return false;

    if(ioctl(port, TIOCEXCL) == -1) { close(); return false; }
    if(fcntl(port, F_SETFL, 0) == -1) { close(); return false; }
    if(tcgetattr(port, &original_attr) == -1) { close(); return false; }

    termios attr = original_attr;
    cfmakeraw(&attr);
    cfsetspeed(&attr, rate);

    attr.c_lflag &=~ (ECHO | ECHONL | ISIG | ICANON | IEXTEN);
    attr.c_iflag &=~ (BRKINT | PARMRK | INPCK | ISTRIP | INLCR | IGNCR | ICRNL | IXON | IXOFF | IXANY);
    attr.c_iflag |=  (IGNBRK | IGNPAR);
    attr.c_oflag &=~ (OPOST);
    attr.c_cflag &=~ (CSIZE | CSTOPB | PARENB | CLOCAL);
    attr.c_cflag |=  (CS8 | CREAD);
    if(flowcontrol == false) {
      attr.c_cflag &= ~CRTSCTS;
    } else {
      attr.c_cflag |=  CRTSCTS;
    }
    attr.c_cc[VTIME] = attr.c_cc[VMIN] = 0;

    if(tcsetattr(port, TCSANOW, &attr) == -1) { close(); return false; }
    return port_open = true;
  }
开发者ID:ARM9,项目名称:bass,代码行数:30,代码来源:serial.hpp


示例3: sbus_init

int
sbus_init(const char *device, bool singlewire)
{
	int sbus_fd = open(device, O_RDWR | O_NONBLOCK);

	if (sbus_fd >= 0) {
		struct termios t;

		/* 100000bps, even parity, two stop bits */
		tcgetattr(sbus_fd, &t);
		cfsetspeed(&t, 100000);
		t.c_cflag |= (CSTOPB | PARENB);
		tcsetattr(sbus_fd, TCSANOW, &t);

		if (singlewire) {
			/* only defined in configs capable of IOCTL */
#ifdef SBUS_SERIAL_PORT
			//ioctl(uart, TIOCSSINGLEWIRE, SER_SINGLEWIRE_ENABLED);
#endif
		}

		/* initialise the decoder */
		partial_frame_count = 0;
		last_rx_time = hrt_absolute_time();
		last_frame_time = last_rx_time;
		sbus_frame_drops = 0;
	}

	return sbus_fd;
}
开发者ID:friekopter,项目名称:Firmware,代码行数:30,代码来源:sbus.c


示例4: sbus_init

int
sbus_init(const char *device)
{
	if (sbus_fd < 0) {
		sbus_fd = open(device, O_RDWR | O_NONBLOCK);
	}

	if (sbus_fd >= 0) {
		struct termios t;

		/* 100000bps, even parity, two stop bits */
		tcgetattr(sbus_fd, &t);
		cfsetspeed(&t, 100000);
		t.c_cflag |= (CSTOPB | PARENB);
		tcsetattr(sbus_fd, TCSANOW, &t);

		/* initialise the decoder */
		partial_frame_count = 0;
		last_rx_time = hrt_absolute_time();

		debug("S.Bus: ready");

	} else {
		debug("S.Bus: open failed");
	}

	return sbus_fd;
}
开发者ID:Bjarne-Madsen,项目名称:Firmware,代码行数:28,代码来源:sbus.c


示例5: port_open

static int port_open(const char *device)
{
	int handle;
	struct termios options;

	/* open serial port */
	if((handle = open( device, O_RDONLY | O_NOCTTY | O_NDELAY)) == -1)
	{
		fprintf(stderr, "error: failed to open serial port (%s)\n", device);
		exit(10);
	}

	/* apply serial port settings */
	tcgetattr(handle, &options);
	cfmakeraw(&options);
	cfsetspeed(&options, TAG_UART_BAUD_RATE);

	if(tcsetattr(handle, TCSANOW, &options))
	{
		fprintf(stderr, "error: failed to set baud %i rate for '%s'\n", TAG_UART_BAUD_RATE, device);
		exit(11);		
	}

	tcflush(handle, TCIFLUSH);

	return handle;
}
开发者ID:meriac,项目名称:openbeacon-ng,代码行数:27,代码来源:openbeacon_sniffer.c


示例6: Dude

int Dude() {

  int fd = open("/dev/ttyAMA0", O_RDWR);
  
  if (fd == -1) {
    perror("/dev/ttyAMA0");
    return 1;
  }
  
  struct termios tios;
  tcgetattr(fd, &tios);
  // disable flow control and all that, and ignore break and parity errors
  tios.c_iflag = IGNBRK | IGNPAR;
  tios.c_oflag = 0;
  tios.c_lflag = 0;
  cfsetspeed(&tios, B9600);
  tcsetattr(fd, TCSAFLUSH, &tios);
  
  // the serial port has a brief glitch once we turn it on which generates a
  // start bit; sleep for 1ms to let it settle
  usleep(1000);    
  
  // output to serial port
  char msg[] = "hi there";
  write(fd, msg, strlen(msg));
  return 0;
}
开发者ID:fojek,项目名称:ProjetCabane,代码行数:27,代码来源:cabanuino.cpp


示例7: IOException

void SerialThrustMasterBase::open() {
    SerialDevice::open();

    struct termios settings;
    if (tcgetattr(handle, &settings) == -1) {
        throw IOException(name + " failed to get termios attributes: " + std::strerror(errno));
    }

    if (cfsetspeed(&settings, B9600) == -1) {
        throw IOException(name + " failed to set baud speed: " + std::strerror(errno));
    }

    // set the terminal to "raw" mode, see TERMIOS(3)
    settings.c_iflag &= ~(IGNBRK | BRKINT | IGNPAR | PARMRK | INPCK | ISTRIP | INLCR | IGNCR | ICRNL | IXON | IXOFF);
    settings.c_oflag &= ~OPOST;
    settings.c_cflag &= ~(CSIZE | PARENB | CSTOPB | HUPCL);
    settings.c_cflag |= CS8 | CLOCAL | CREAD;
    settings.c_lflag &= ~(ISIG | ICANON | ECHO | ECHOE | ECHOK | ECHONL | IEXTEN);
    settings.c_cc[VTIME] = 0;
    settings.c_cc[VMIN] = 0;

    if (tcsetattr(handle, TCSANOW, &settings) == -1) {
        throw IOException(name + " failed to set termios attributes: " + std::strerror(errno));
    }

    // start getting data
    requestData();
}
开发者ID:nasa,项目名称:IDF,代码行数:28,代码来源:SerialThrustMasterBase.cpp


示例8: set_baudrate

static int set_baudrate(int fd, int baudrate, int hwflow)
{
	int i;
	u_int32_t bd = 0;
	struct termios ti;

	for (i = 0; i < ARRAY_SIZE(bdrts); i++) {
		if (bdrts[i].bps == baudrate)
			bd = bdrts[i].b;
	}
	if (bd == 0)
		return -EINVAL;

	i = tcgetattr(fd, &ti);
	if (i < 0)
		return -errno;

	tcflush(fd, TCIOFLUSH);
	cfmakeraw(&ti);

	i = cfsetspeed (&ti, bd);
	if (i < 0)
		return -errno;

	if (hwflow)
		ti.c_cflag |= CRTSCTS;
	else
		ti.c_cflag &= ~CRTSCTS;

	return tcsetattr(fd, TCSANOW, &ti) ? -errno : 0;
}
开发者ID:vovan888,项目名称:linux-on-sx1,代码行数:31,代码来源:gsmd.c


示例9: openSerialDevice

int openSerialDevice(const char * name, int baud, int parity, int databits, int stopbits) {
	/* open serial device; return file descriptor or -1 for error (see errno) */
	int fd, res;
	struct termios newSettings;
	
	if (strchr(name, ':')) 
		return openSerialSocket(name);
	
	if ((fd = open(name, O_RDWR | O_NOCTTY)) < 0) return fd;        // an error code
	
	bzero(&newSettings, sizeof(newSettings));
	// Control Modes
	newSettings.c_cflag = databits | CLOCAL | CREAD; // CRTSCTS stops it working on TS-SER1 & TS-SER4
	if (stopbits == 2)
		newSettings.c_cflag |= CSTOPB;
	// input modes
	cfsetspeed(&newSettings, baud);
	newSettings.c_iflag = IGNPAR;   //input modes
	newSettings.c_oflag = 0;                // output modes
	newSettings.c_lflag = 0;                // local flag
	newSettings.c_cc[VTIME] = 0; // intercharacter timer */
    newSettings.c_cc[VMIN] = 0;     // non-blocking read */
	tcflush(fd, TCIFLUSH);          // discard pending data
	//      cfsetospeed(&newSettings, baud);
	if((res = tcsetattr(fd, TCSANOW, &newSettings)) < 0) {
		close(fd);      // if there's an error setting values, return the error code
		return res;
	}
	return fd;
}
开发者ID:Cybercontrolsystems,项目名称:mcp,代码行数:30,代码来源:common.c


示例10: baud_name_to_flags

int serial_handler::set_baud(const char *baud_name)
{
	struct termios port_setting;
	tcflag_t baud;
	int r;

	if (port_fd < 0) return -1;
	baud = baud_name_to_flags(baud_name);
	if (baud == B0) return -2;
	r = tcgetattr(port_fd, &port_setting);
	if (r != 0) return -3;
#ifdef __APPLE__
	cfsetspeed(&port_setting,baud);
	port_setting.c_iflag = IGNBRK | IGNPAR;
	port_setting.c_cflag =  CS8 | CREAD | HUPCL | CLOCAL;
#else
	port_setting.c_iflag = IGNBRK | IGNPAR;
	port_setting.c_cflag = baud | CS8 | CREAD | HUPCL | CLOCAL;
#endif

	port_setting.c_oflag = 0;
	port_setting.c_lflag = 0;
	r = tcsetattr(port_fd, TCSAFLUSH, &port_setting);
	if (r != 0) return -4;
	return 0;
}
开发者ID:BytesGalore,项目名称:MyMsbA2Tools,代码行数:26,代码来源:serial.cpp


示例11: rpi_comport_open

int rpi_comport_open(char *devpathname)
{
    struct termios newtio;
    
    /* If already opened, just return the fd */
    if (fd_comport > 0)
	return fd_comport;
    /* open the device to be non-blocking (read will return immediately) */
    fd_comport = open(devpathname, O_RDWR | O_NOCTTY | O_NONBLOCK);
    if (fd_comport < 0) {
	perror(devpathname);
	return -1;
    }
    /* save current port settings */
    tcgetattr(fd_comport, &oldtio);
    /* set new port settings for raw & non-canonical input processing */
    cfmakeraw(&newtio);
    cfsetspeed(&newtio, B9600);
    /* minimum one character, or 1 character timeout */
    newtio.c_cc[VMIN] = 0;
    newtio.c_cc[VTIME] = 0;
    tcflush(fd_comport, TCIOFLUSH);
    tcsetattr(fd_comport, TCSANOW, &newtio);
    return 0;
}
开发者ID:BackupGGCode,项目名称:raspy-juice,代码行数:25,代码来源:rpi-daq.c


示例12: lua_stty_speed

static int lua_stty_speed(lua_State *L) {
  int fd = lua_tofd(L, 1);
  int speed = luaL_checkint(L,2);

#ifdef __APPLE__
  if (ioctl(fd, IOSSIOSPEED, &speed) == -1)
    return luaL_error(L, "Could not set speed.");
#else
  // Default termios interface
  struct termios tio;
  if (tcgetattr(fd, &tio) != 0) {
    return luaL_error(L, "Could not get termios");
  }
  if (cfsetspeed(&tio, speed) != 0) {
    return luaL_error(L, "Could not set speed");
  }
  if (tcsetattr(fd, TCSANOW, &tio) != 0) {
    return luaL_error(L, "Could not set termios");
  }

  // For linux:
  struct serial_struct serinfo;
  if (ioctl(fd, TIOCGSERIAL, &serinfo) < 0)
    return luaL_error(L, "Could not get serial info.");
  serinfo.flags &= ~ASYNC_SPD_MASK;
  serinfo.flags |= ASYNC_SPD_CUST;
  serinfo.custom_divisor = serinfo.baud_base/((float)speed);
  if (ioctl(fd, TIOCSSERIAL, &serinfo) < 0)
    return luaL_error(L, "Could not set serial info.");

#endif

  return 0;
}
开发者ID:Arista12,项目名称:UPennalizers,代码行数:34,代码来源:luastty.cpp


示例13: config_port_serie

// Paramétrage du port série
int config_port_serie()
{
    int handle;

    char uart[20]= {"/dev/ttyUSB0"};

    //Ouverture du port série
    handle=open ( uart, O_RDWR | O_NOCTTY | O_NDELAY );

    if ( handle<0 )
    {
        perror ( "serial port fail to open\n" );
        exit(0);
    }
    else
    {
        if(fcntl ( handle, F_SETFL, FNDELAY)<0)
            perror("fcntl");
    }


    //settings for the uart
    tcgetattr ( handle, &option );
    cfmakeraw ( &option );
    cfsetspeed ( &option, B9600 );
    option.c_cflag |= ( CLOCAL | CREAD | CS8 );
    option.c_cflag &= ( ~PARENB & ~CSTOPB & ~CRTSCTS & ~CSIZE);

    tcsetattr ( handle, TCSANOW, &option );

    return handle;
}
开发者ID:byrddev,项目名称:paparazzi,代码行数:33,代码来源:SMS_Ground_UDtest_final.c


示例14: Java_gnu_io_RS485Port_nativeSetRS485PortParams

/*----------------------------------------------------------
 RS485Port.nativeSetRS485PortParams

   accept:     speed, data bits, stop bits, parity
   perform:    set the RS485 port parameters
   return:     void
   exceptions: UnsupportedCommOperationException
----------------------------------------------------------*/ 
JNIEXPORT void JNICALL Java_gnu_io_RS485Port_nativeSetRS485PortParams(
	JNIEnv *env, jobject jobj, jint speed, jint dataBits, jint stopBits,
	jint parity )
{
	struct termios ttyset;
	int fd = get_java_var( env, jobj,"fd","I" );
	int cspeed = translate_speed( env, speed );
	if( !cspeed ) return;
	if( tcgetattr( fd, &ttyset ) < 0 ) goto fail;
	if( !translate_data_bits( env, (int *)&(ttyset.c_cflag), dataBits ) ) return; /* dima c_cflag in darwin is unsigned long */
	if( !translate_stop_bits( env, (int *)&(ttyset.c_cflag), stopBits ) ) return; /* dima c_cflag in darwin is unsigned long */
	if( !translate_parity( env, (int *)&(ttyset.c_cflag), parity ) ) return;/* dima c_cflag in darwin is unsigned long */
#ifdef __FreeBSD__
	if( cfsetspeed( &ttyset, cspeed ) < 0 ) goto fail;
#else
	if( cfsetispeed( &ttyset, cspeed ) < 0 ) goto fail;
	if( cfsetospeed( &ttyset, cspeed ) < 0 ) goto fail;
#endif
	if( tcsetattr( fd, TCSANOW, &ttyset ) < 0 ) goto fail;
	/* dump_termios("set",*ttyset); */
	return;

fail:
	throw_java_exception( env, UNSUPPORTED_COMM_OPERATION,
		"nativeSetRS485PortParams", strerror( errno ) );
}
开发者ID:chrisdew,项目名称:rxtx,代码行数:34,代码来源:RS485Imp.c


示例15: serial_port_set_baudrate

int serial_port_set_baudrate(struct serial_port_t* _ctx,
                             unsigned int _baudrate) {
    if(_ctx) {
        struct termios tt;
        int r;
        speed_t speed;

        if((r = tcgetattr(_ctx->fd, &tt)))
            return r;

        speed = posix_serial_port_get_speedt_by_baudrate(_baudrate);

        if((r = cfsetspeed(&tt, speed)))
           return r;

        //cfsetispeed(&tt, speed);
        //cfsetospeed(&tt, speed);

        if((r = tcsetattr(_ctx->fd, TCSANOW, &tt)))
           return r;

        return 0;
    }
    else
        return -EINVAL;
}
开发者ID:alexander-nik1,项目名称:emodbus,代码行数:26,代码来源:serial-port.c


示例16: main

int main(int argc,char *argv[]) {
  int i,fd,slen;
  char *s;
  unsigned char c;
  struct iovec iov[5];
  speed_t br=DEFAULT_BAUDRATE;
  struct termios tios;

  if(argc<3) {
    printf("syntax: %s tty [baudrate (default=%d)] text\n", *argv, br2i(br));
    return 1;
  }

  if(-1==(fd=open(argv[1],O_RDWR))) {
    perror("open");
    return 1;
  }

  if(argc>3)
    br=str2br(argv[2]);

  if(-1==tcgetattr(fd,&tios)) {
    perror("tcgetattr");
    return 1;
  }
  cfmakeraw(&tios);
  printf("setting baudrate %d\n",br2i(br));
  if(-1==cfsetspeed(&tios,br)) {
    perror("cfsetspeed");
    return 1;
  }
  if(-1==tcsetattr(fd,TCSANOW,&tios)) {
    perror("tcgetattr");
    return 1;
  }

  i=0;
  iov_set(iov,i++,"\xff",1);
  iov_set(iov,i++,"\x06\xa2",2);

  s=argv[argc>3?3:2];
  slen=strlen(s);
  iov_set(iov,i++,s,slen);

  c=cksum(6+162,s,slen);
  iov_set(iov,i++,&c,1);

  iov_set(iov,i++,"\xff",1);

  printf("writing %d bytes\n",5+slen);
  xxdv(iov,i);
  if(-1==(i=writev(fd,iov,i)))
    perror("writev");
  else
    printf("%d bytes written\n",i);

  close(fd);
  return i!=5+slen;
}
开发者ID:qzio,项目名称:flip-disc-widget,代码行数:59,代码来源:print_to_display.c


示例17: main

int main(int argc, const char *argv[])
{
	int serialFD;
	int x;
	int y;
	unsigned short color;
	struct termios serialopts;
	FILE *imageFile;
	
	imageFile = fopen(argv[1], "rb");
	if (imageFile == NULL)
	{
		perror("couldn't open file");
		return 1;
	}
	
	serialFD = open("/dev/cu.usbserial", O_RDWR | O_NOCTTY);
	if (serialFD < 0)
	{
		perror("couldn't open serial port");
		return 1;
	}
	
	if (tcgetattr(serialFD, &serialopts) != 0)
	{
		perror("Unable to get serial port options");
		return 1;
	}
	
	serialopts.c_cflag = CS8 | CLOCAL | CREAD;
	cfmakeraw(&serialopts);
	cfsetspeed(&serialopts, B115200);

	if (tcsetattr(serialFD, TCSANOW, &serialopts) != 0)
	{
		perror("Unable to initialize serial port");
		return 1;
	}
	
	for (x = 0; x < 640 * 480; x++)
	{
		unsigned char triple[4];
		if (fread(triple, 3, 1, imageFile) <= 0)
		{
			perror("error reading file");
			break;
		}

		triple[3] = 0xFF;
		if (write(serialFD, triple, 4) != 4)
		{
			perror("write");
			break;
		}
	}	
	
	close(serialFD);
	return 0;
}
开发者ID:ADonut,项目名称:GPGPU,代码行数:59,代码来源:push_bitmap.c


示例18: serial_changespeed

/*
 * Change the speed of the serial device.
 * RETURNS: Success
 */
gn_error serial_changespeed(int fd, int speed, struct gn_statemachine *state)
{
	gn_error retcode = GN_ERR_NONE;
#ifndef SGTTY
	struct termios t;
#else
	struct sgttyb t;
#endif
	int new_speed = B9600;

	switch (speed) {
	case 0:
		dprintf("Not setting port speed\n");
		return GN_ERR_NOTSUPPORTED;
	case 2400:
		new_speed = B2400;
		break;
	case 4600:
		new_speed = B4800;
		break;
	case 9600:
		new_speed = B9600;
		break;
	case 19200:
		new_speed = B19200;
		break;
	case 38400:
		new_speed = B38400;
		break;
	case 57600:
		new_speed = B57600;
		break;
	case 115200:
		new_speed = B115200;
		break;
	default:
		fprintf(stderr, _("Serial port speed %d not supported!\n"), speed);
		return GN_ERR_NOTSUPPORTED;
	}

#ifndef SGTTY
	if (tcgetattr(fd, &t)) retcode = GN_ERR_INTERNALERROR;

	if (cfsetspeed(&t, new_speed) == -1) {
		dprintf("Serial port speed setting failed\n");
		retcode = GN_ERR_INTERNALERROR;
	}

	tcsetattr(fd, TCSADRAIN, &t);
#else
	if (ioctl(fd, TIOCGETP, &t)) retcode = GN_ERR_INTERNALERROR;

	t.sg_ispeed = new_speed;
	t.sg_ospeed = new_speed;

	if (ioctl(fd, TIOCSETN, &t)) retcode = GN_ERR_INTERNALERROR;
#endif
	return retcode;
}
开发者ID:tal-nino,项目名称:gnokii,代码行数:63,代码来源:unixserial.c


示例19: memset

void UARTDevice::set_speed(uint32_t baudrate)
{
    struct termios t;
    memset(&t, 0, sizeof(t));

    tcgetattr(_fd, &t);
    cfsetspeed(&t, baudrate);
    tcsetattr(_fd, TCSANOW, &t);
}
开发者ID:Rusty105,项目名称:ardupilot,代码行数:9,代码来源:UARTDevice.cpp


示例20: serial_open

int serial_open(int port, int initial_baud, int final_baud){
	int port_id;
	struct termios t_port;
    #ifdef USB
		char COM_PORT[16]="/dev/ttyUSB0";
    #else
	   char COM_PORT[16]="/dev/ttyS0";
    #endif
	int baud_rate[] = {B4800,B9600,B19200,B38400,B57600,B115200};

    #ifdef USB
	   printf("USB case");
	   COM_PORT[11] = COM_PORT[11] + port;
    #else
	   printf("Serial case");
	   COM_PORT[9] = COM_PORT[9] + port;
    #endif
	printf("Initializing communications port %s...", COM_PORT);

	/* open the device */
	if ((port_id = open(COM_PORT, O_RDWR)) == -1){
		printf("can not open device %s", COM_PORT);
		exit(1); }

	if (tcgetattr(port_id, &t_port) < 0){
		printf("error initiallizing %s", COM_PORT);
		exit(1); }

	t_port.c_iflag &= ~(BRKINT | ICRNL | INPCK | ISTRIP | IXON); // input mode
		/* no SIGINT on BREAK, CRNL off, parity off,8th bit strip off, output flow ctrl off */
	t_port.c_oflag &= ~(OPOST); // output mode
		/* output processing off */
	t_port.c_cflag &= ~(CSIZE | PARENB); // control mode
		/* clear size bits, parity off */
	t_port.c_cflag |=  baud_rate[final_baud] | CS8 | CREAD | CLOCAL ;
	t_port.c_cflag &= ~(CRTSCTS | CSTOPB);
		// 4800 9600 19200 38400 57600 115200
		/* 8 bits/char, enable receiver, close modem when exit */
	t_port.c_lflag &= ~(ECHO | ICANON | IEXTEN | ISIG);
		/* echo off, canonical mode off,extended input processing off, signal chars off */

	t_port.c_cc[VMIN] = 0;//MIN_MSG_SIZE;		// wait for the amount of VMIN byte
	t_port.c_cc[VTIME] = 10;    /* waits 1/10ths of sec for reply */

	if (cfsetspeed(&t_port, baud_rate[final_baud]) < 0) {
		printf("error initiallizing %s", COM_PORT);
		exit(1); }
	if (tcsetattr(port_id, TCSANOW, &t_port) < 0){
		printf("error initiallizing %s", COM_PORT);
		exit(1); }
    //sleep(2);
	if (tcgetattr(port_id, &t_port) < 0){
		printf("error initiallizing %s", COM_PORT);
		exit(1); }

	return port_id; }
开发者ID:crag47,项目名称:ECE4330_competition,代码行数:56,代码来源:serial_talk.c



注:本文中的cfsetspeed函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ cfw_send_message函数代码示例发布时间:2022-05-30
下一篇:
C++ cfsetospeed函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap