您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ tty_write函数代码示例

51自学网 2021-06-03 09:00:46
  C++
这篇教程C++ tty_write函数代码示例写得很实用,希望能帮到您。

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

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

示例1: ttym_write

static ssize_t ttym_write(dev_cookie _cookie, const void *buf, off_t pos, ssize_t len){	tty_master_cookie *cookie = (tty_master_cookie *)_cookie;	ssize_t ret;	TRACE(("ttym_write: tty %d cookie %p, buf %p, len %d/n", cookie->tty->index, cookie, buf, len));	ret = tty_write(cookie->tty, buf, len, ENDPOINT_MASTER_WRITE);	TRACE(("ttym_write: tty %d returns %d/n", cookie->tty->index, ret));	return ret;}
开发者ID:HTshandou,项目名称:newos,代码行数:13,


示例2: screen_write_deleteline

/* Delete ny lines. */voidscreen_write_deleteline(struct screen_write_ctx *ctx, u_int ny){	struct screen	*s = ctx->s;	struct tty_ctx	 ttyctx;	if (ny == 0)		ny = 1;	if (s->cy < s->rupper || s->cy > s->rlower) {		if (ny > screen_size_y(s) - s->cy)			ny = screen_size_y(s) - s->cy;		if (ny == 0)			return;		screen_write_initctx(ctx, &ttyctx, 0);		grid_view_delete_lines(s->grid, s->cy, ny);		ttyctx.num = ny;		tty_write(tty_cmd_deleteline, &ttyctx);		return;	}	if (ny > s->rlower + 1 - s->cy)		ny = s->rlower + 1 - s->cy;	if (ny == 0)		return;	screen_write_initctx(ctx, &ttyctx, 0);	if (s->cy < s->rupper || s->cy > s->rlower)		grid_view_delete_lines(s->grid, s->cy, ny);	else		grid_view_delete_lines_region(s->grid, s->rlower, s->cy, ny);	ttyctx.num = ny;	tty_write(tty_cmd_deleteline, &ttyctx);}
开发者ID:Stichting-MINIX-Research-Foundation,项目名称:minix,代码行数:40,


示例3: check_ieqpro_connection

bool check_ieqpro_connection(int fd){  char initCMD[] = ":V#";  int errcode = 0;  char errmsg[MAXRBUF];  char response[8];  int nbytes_read=0;  int nbytes_written=0;  DEBUGDEVICE(ieqpro_device, INDI::Logger::DBG_DEBUG, "Initializing IOptron using :V# CMD...");  for (int i=0; i < 2; i++)  {      if (ieqpro_simulation)      {          strcpy(response, "V1.00#");          nbytes_read= strlen(response);      }      else      {          if ( (errcode = tty_write(fd, initCMD, 3, &nbytes_written)) != TTY_OK)          {              tty_error_msg(errcode, errmsg, MAXRBUF);              DEBUGFDEVICE(ieqpro_device, INDI::Logger::DBG_ERROR, "%s", errmsg);              usleep(50000);              continue;          }          if ( (errcode = tty_read_section(fd, response, '#', IEQPRO_TIMEOUT, &nbytes_read)))          {              tty_error_msg(errcode, errmsg, MAXRBUF);              DEBUGFDEVICE(ieqpro_device, INDI::Logger::DBG_ERROR, "%s", errmsg);              usleep(50000);              continue;          }      }      if (nbytes_read > 0)      {        response[nbytes_read] = '/0';        DEBUGFDEVICE(ieqpro_device, INDI::Logger::DBG_DEBUG, "RES (%s)", response);        if (!strcmp(response, "V1.00#"))            return true;      }      usleep(50000);  }  return false;}
开发者ID:daggerstab,项目名称:indi,代码行数:51,


示例4: set_ieqpro_ra

bool set_ieqpro_ra(int fd, double ra){    char cmd[32];    int errcode = 0;    char errmsg[MAXRBUF];    char response[8];    int nbytes_read=0;    int nbytes_written=0;    // Send as milliseconds resolution    int ieqValue = ra * 60 * 60 * 1000;    snprintf(cmd, 32, ":Sr%08d#", ieqValue);    DEBUGFDEVICE(ieqpro_device, INDI::Logger::DBG_DEBUG, "CMD (%s)", cmd);    if (ieqpro_simulation)    {        simData.ra = ra;        strcpy(response, "1");        nbytes_read = strlen(response);    }    else    {        if ( (errcode = tty_write(fd, cmd, strlen(cmd), &nbytes_written)) != TTY_OK)        {            tty_error_msg(errcode, errmsg, MAXRBUF);            DEBUGFDEVICE(ieqpro_device, INDI::Logger::DBG_ERROR, "%s", errmsg);            return false;        }        if ( (errcode = tty_read(fd, response, 1, IEQPRO_TIMEOUT, &nbytes_read)))        {            tty_error_msg(errcode, errmsg, MAXRBUF);            DEBUGFDEVICE(ieqpro_device, INDI::Logger::DBG_ERROR, "%s", errmsg);            return false;        }    }    if (nbytes_read > 0)    {      response[nbytes_read] = '/0';      DEBUGFDEVICE(ieqpro_device, INDI::Logger::DBG_DEBUG, "RES (%s)", response);      tcflush(fd, TCIFLUSH);      return true;    }    DEBUGFDEVICE(ieqpro_device, INDI::Logger::DBG_ERROR, "Only received #%d bytes, expected 1.", nbytes_read);    return false;}
开发者ID:daggerstab,项目名称:indi,代码行数:51,


示例5: task_tty

/*======================================================================*                           task_tty *======================================================================*/PUBLIC void task_tty(){	TTY*	p_tty;	MSG 	msg;	init_keyboard();	for (p_tty=TTY_FIRST;p_tty<TTY_END;p_tty++) {		init_tty(p_tty);	}	select_console(0);	//清屏	clear(TTY_FIRST);	//欢迎信息	printf("X-Tinix./n");	printf("X-Tinix: TTY(TASK) loaded./n");		//就绪消息	_send(PID_SERVICE_PROC ,MSG_TYPE_TTY_READY);	_recv(MSG_TYPE_PROC_READY);	_send(PID_SERVICE_SHELL,MSG_TYPE_TTY_READY);	//监听消息	while (1) {		if(recv(ANY_MSG_SRC,&msg)!=-1){			SHELL_MSG shell_msg;			memcpy(&shell_msg,msg.msg,sizeof(SHELL_MSG));			switch(msg.type){				case MSG_TYPE_SHELL:					tty_write(TTY_FIRST+shell_msg.tty,shell_msg.command,strlen(shell_msg.command));					break;				case MSG_TYPE_TTY_CLEAR:					p_tty = TTY_FIRST + shell_msg.tty;					clear(p_tty);					break;				default:					break;			}		}		for (p_tty=TTY_FIRST;p_tty<TTY_END;p_tty++) {			tty_do_read(p_tty);			//tty_do_write(p_tty);		}		//clean work		memset(&msg,0x0,sizeof(MSG));	}}
开发者ID:lizhengqiang,项目名称:tinix,代码行数:54,


示例6: DEBUGF

int ioptronHC8406::SendPulseCmd(int direction, int Tduration_msec){    DEBUGF(INDI::Logger::DBG_DEBUG, "<%s>", __FUNCTION__);    int rc = 0,  nbytes_written = 0;    char cmd[20];    int duration_msec,Rduration;    if (Tduration_msec >=1000) {	    duration_msec=999;    		    //limited to 999	    Rduration=Tduration_msec-duration_msec; //pending ms    } else {	    duration_msec=Tduration_msec;	    Rduration=0;       	    DEBUGF(INDI::Logger::DBG_DEBUG, "Pulse %d <999 Sent only one",Tduration_msec);    }    switch (direction)    {        case LX200_NORTH:            sprintf(cmd, ":Mn%03d#", duration_msec);            break;        case LX200_SOUTH:            sprintf(cmd, ":Ms%03d#", duration_msec);            break;        case LX200_EAST:            sprintf(cmd, ":Me%03d#", duration_msec);            break;        case LX200_WEST:            sprintf(cmd, ":Mw%03d#", duration_msec);            break;        default:            return 1;    }    DEBUGF(INDI::Logger::DBG_DEBUG, "CMD <%s>", cmd);    if ((rc = tty_write(PortFD, cmd, strlen(cmd), &nbytes_written)) != TTY_OK)    {        char errmsg[256];        tty_error_msg(rc, errmsg, 256);        DEBUGF(INDI::Logger::DBG_ERROR, "Error writing to device %s (%d)", errmsg, rc);        return 1;    }    tcflush(PortFD, TCIFLUSH);    if (Rduration!=0) {    	DEBUGF(INDI::Logger::DBG_DEBUG, "pulse guide. Pulse >999. ms left:%d",Rduration);        usleep(1000000);   //wait until the previous one has fineshed        return SendPulseCmd(direction,Rduration);    }    return 0;}
开发者ID:rrogge,项目名称:indi,代码行数:50,


示例7: dev_uart_write

static size_t dev_uart_write(struct file_desc *desc, void *buff, size_t size) {	struct uart *uart_dev = desc->file_info;	struct tty *tty = &uart_dev->tty;	size_t written, left = size;	do {		written = tty_write(tty, buff, left);		left -= written;		buff = (char *) buff + written;	} while (left != 0);	return size;}
开发者ID:vadimsmirnovnsk,项目名称:embox,代码行数:14,


示例8: tcflush

bool MoonLite::Ack(){    int nbytes_written = 0, nbytes_read = 0, rc = -1;    char errstr[MAXRBUF];    char resp[5]={0};    short pos = -1;    tcflush(PortFD, TCIOFLUSH);    //Try to request the position of the focuser    //Test for success on transmission and response    //If either one fails, try again, up to 3 times, waiting 1 sec each time    //If that fails, then return false.    int numChecks = 0;    bool success = false;    while(numChecks < 3 && !success)    {        numChecks++;        sleep(1); //wait 1 second between each test.        bool transmissionSuccess = (rc = tty_write(PortFD, ":GP#", 4, &nbytes_written)) == TTY_OK;        if(!transmissionSuccess)        {            tty_error_msg(rc, errstr, MAXRBUF);            LOGF_ERROR("Handshake Attempt %i, tty transmission error: %s.", numChecks, errstr);        }        bool responseSuccess = (rc = tty_read(PortFD, resp, 5, MOONLITE_TIMEOUT, &nbytes_read)) == TTY_OK;        if(!responseSuccess)        {            tty_error_msg(rc, errstr, MAXRBUF);            LOGF_ERROR("Handshake Attempt %i, updatePosition response error: %s.", numChecks, errstr);        }        success = transmissionSuccess && responseSuccess;    }    if(!success)    {        LOG_INFO("Handshake failed after 3 attempts");        return false;    }    tcflush(PortFD, TCIOFLUSH);    rc = sscanf(resp, "%hX#", &pos);    return rc > 0;}
开发者ID:djibb,项目名称:indi,代码行数:50,


示例9: printf

int printf(const char *fmt, ...){    int i;    char buf[512];    va_list args;    va_start(args, fmt);    i = vsprintf(buf, fmt, args);    tty_write(&tty0, buf, i);    va_end(args);    return i;}
开发者ID:wind4869,项目名称:Owindy-S,代码行数:14,


示例10: set_ieqpro_daylight_saving

bool set_ieqpro_daylight_saving(int fd, bool enabled){    char cmd[16];    int errcode = 0;    char errmsg[MAXRBUF];    char response[8];    int nbytes_read=0;    int nbytes_written=0;    if (enabled)        strcpy(cmd, ":SDS1#");    else        strcpy(cmd, ":SDS0#");    DEBUGFDEVICE(ieqpro_device, INDI::Logger::DBG_DEBUG, "CMD (%s)", cmd);    if (ieqpro_simulation)    {        strcpy(response, "1");        nbytes_read = strlen(response);    }    else    {        if ( (errcode = tty_write(fd, cmd, strlen(cmd), &nbytes_written)) != TTY_OK)        {            tty_error_msg(errcode, errmsg, MAXRBUF);            DEBUGFDEVICE(ieqpro_device, INDI::Logger::DBG_ERROR, "%s", errmsg);            return false;        }        if ( (errcode = tty_read(fd, response, 1, IEQPRO_TIMEOUT, &nbytes_read)))        {            tty_error_msg(errcode, errmsg, MAXRBUF);            DEBUGFDEVICE(ieqpro_device, INDI::Logger::DBG_ERROR, "%s", errmsg);            return false;        }    }    if (nbytes_read > 0)    {      response[nbytes_read] = '/0';      DEBUGFDEVICE(ieqpro_device, INDI::Logger::DBG_DEBUG, "RES (%s)", response);      tcflush(fd, TCIFLUSH);      return true;    }    DEBUGFDEVICE(ieqpro_device, INDI::Logger::DBG_ERROR, "Only received #%d bytes, expected 1.", nbytes_read);    return false;}
开发者ID:daggerstab,项目名称:indi,代码行数:50,


示例11: DEBUG

/************************************************************************************ ** ***********************************************************************************/IPState BaaderDome::MoveAbs(double az){    int nbytes_written = 0, nbytes_read = 0, rc = -1;    char errstr[MAXRBUF];    char cmd[DOME_BUF];    char resp[DOME_BUF];    if (status == DOME_UNKNOWN)    {        DEBUG(INDI::Logger::DBG_WARNING, "Dome is not calibrated. Please calibrate dome before issuing any commands.");        return IPS_ALERT;    }    targetAz = az;    snprintf(cmd, DOME_BUF, "d#azi%04d", MountAzToDomeAz(targetAz));    tcflush(PortFD, TCIOFLUSH);    if (!sim && (rc = tty_write(PortFD, cmd, DOME_CMD, &nbytes_written)) != TTY_OK)    {        tty_error_msg(rc, errstr, MAXRBUF);        DEBUGF(INDI::Logger::DBG_ERROR, "%s MoveAbsDome error: %s.", cmd, errstr);        return IPS_ALERT;    }    DEBUGF(INDI::Logger::DBG_DEBUG, "CMD (%s)", cmd);    if (sim)    {        strncpy(resp, "d#gotmess", DOME_CMD);        nbytes_read = DOME_CMD;    }    else if ((rc = tty_read(PortFD, resp, DOME_CMD, DOME_TIMEOUT, &nbytes_read)) != TTY_OK)    {        tty_error_msg(rc, errstr, MAXRBUF);        DEBUGF(INDI::Logger::DBG_ERROR, "MoveAbsDome error: %s.", errstr);        return IPS_ALERT;    }    resp[nbytes_read] = '/0';    DEBUGF(INDI::Logger::DBG_DEBUG, "RES (%s)", resp);    if (strcmp(resp, "d#gotmess") == 0)        return IPS_BUSY;    return IPS_ALERT;}
开发者ID:rrogge,项目名称:indi,代码行数:52,


示例12: start_ieqpro_guide

bool start_ieqpro_guide(int fd,  IEQ_DIRECTION dir, int ms){    char cmd[16];    int errcode = 0;    char errmsg[MAXRBUF];    char response[8];    int nbytes_read=0;    int nbytes_written=0;    char dir_c;    switch (dir)    {        case IEQ_N:           dir_c = 'n';           break;        case IEQ_S:           dir_c = 's';           break;        case IEQ_W:           dir_c = 'w';           break;        case IEQ_E:           dir_c = 'e';           break;    }    snprintf(cmd, 16, ":M%c%05d#", dir_c, ms );    DEBUGFDEVICE(ieqpro_device, INDI::Logger::DBG_DEBUG, "CMD (%s)", cmd);    if (ieqpro_simulation)        return true;    else    {        if ( (errcode = tty_write(fd, cmd, strlen(cmd), &nbytes_written)) != TTY_OK)        {            tty_error_msg(errcode, errmsg, MAXRBUF);            DEBUGFDEVICE(ieqpro_device, INDI::Logger::DBG_ERROR, "%s", errmsg);            return false;        }    }    tcflush(fd, TCIFLUSH);    return true;}
开发者ID:daggerstab,项目名称:indi,代码行数:49,


示例13: set_ieqpro_guide_rate

bool set_ieqpro_guide_rate(int fd, double rate){    char cmd[16];    int errcode = 0;    char errmsg[MAXRBUF];    char response[8];    int nbytes_read=0;    int nbytes_written=0;    int num = rate * 100;    snprintf(cmd, 16, ":RG%03d#", num );    DEBUGFDEVICE(ieqpro_device, INDI::Logger::DBG_DEBUG, "CMD (%s)", cmd);    if (ieqpro_simulation)    {        simData.guide_rate = rate;        strcpy(response, "1");        nbytes_read = strlen(response);    }    else    {        if ( (errcode = tty_write(fd, cmd, strlen(cmd), &nbytes_written)) != TTY_OK)        {            tty_error_msg(errcode, errmsg, MAXRBUF);            DEBUGFDEVICE(ieqpro_device, INDI::Logger::DBG_ERROR, "%s", errmsg);            return false;        }        if ( (errcode = tty_read(fd, response, 1, IEQPRO_TIMEOUT, &nbytes_read)))        {            tty_error_msg(errcode, errmsg, MAXRBUF);            DEBUGFDEVICE(ieqpro_device, INDI::Logger::DBG_ERROR, "%s", errmsg);            return false;        }    }    if (nbytes_read > 0)    {      response[nbytes_read] = '/0';      DEBUGFDEVICE(ieqpro_device, INDI::Logger::DBG_DEBUG, "RES (%s)", response);      tcflush(fd, TCIFLUSH);      return true;    }    DEBUGFDEVICE(ieqpro_device, INDI::Logger::DBG_ERROR, "Only received #%d bytes, expected 1.", nbytes_read);    return false;}
开发者ID:daggerstab,项目名称:indi,代码行数:49,


示例14: screen_write_reverseindex

/* Reverse index (up with scroll).  */voidscreen_write_reverseindex(struct screen_write_ctx *ctx){	struct screen	*s = ctx->s;	struct tty_ctx	 ttyctx;	screen_write_initctx(ctx, &ttyctx, 0);	if (s->cy == s->rupper)		grid_view_scroll_region_down(s->grid, s->rupper, s->rlower);	else if (s->cy > 0)		s->cy--;	tty_write(tty_cmd_reverseindex, &ttyctx);}
开发者ID:HonestQiao,项目名称:tmux,代码行数:16,


示例15: tcflush

bool XAGYLWheel::getOffset(int filter){    int nbytes_written=0, nbytes_read=0, rc=-1;    char errstr[MAXRBUF];    char command[XAGYL_MAXBUF];    char resp[XAGYL_MAXBUF];    tcflush(PortFD, TCIOFLUSH);    snprintf(command, XAGYL_MAXBUF, "O%d", filter+1);    DEBUGF(INDI::Logger::DBG_DEBUG, "CMD (%s)", command);    if (!sim && (rc = tty_write(PortFD, command, strlen(command), &nbytes_written)) != TTY_OK)    {        tty_error_msg(rc, errstr, MAXRBUF);        DEBUGF(INDI::Logger::DBG_ERROR, "%s error: %s.", command, errstr);        return false;    }    if (sim)           snprintf(resp, XAGYL_MAXBUF, "P%d Offset %02d", filter+1, simData.offset[filter]);    else    {        if ( (rc = tty_read_section(PortFD, resp, 0xA, XAGYL_MAXBUF, &nbytes_read)) != TTY_OK)        {            tty_error_msg(rc, errstr, MAXRBUF);            DEBUGF(INDI::Logger::DBG_ERROR, "%s: %s.", command, errstr);            return false;        }        resp[nbytes_read-1] = '/0';    }    DEBUGF(INDI::Logger::DBG_DEBUG, "RES (%s)", resp);    int filter_num=0, offset=0;    rc = sscanf(resp, "P%d Offset %d", &filter_num, &offset);    if (rc > 0)    {        OffsetN[filter_num-1].value = offset;        return true;    }    else        return false;}
开发者ID:phomer60,项目名称:indi,代码行数:48,


示例16: memset

bool SynscanDriver::passThruCommand(int cmd, int target, int msgsize, int data, int numReturn){    char test[20] = {0};    int bytesRead, bytesWritten;    char a, b, c;    int tt = data;    a  = tt % 256;    tt = tt >> 8;    b  = tt % 256;    tt = tt >> 8;    c  = tt % 256;    //  format up a passthru command    memset(test, 0, 20);    test[0] = 80;      // passhtru    test[1] = msgsize; // set message size    test[2] = target;  // set the target    test[3] = cmd;     // set the command    test[4] = c;       // set data bytes    test[5] = b;    test[6] = a;    test[7] = numReturn;    LOGF_DEBUG("CMD <%s>", test);    tty_write(PortFD, test, 8, &bytesWritten);    memset(test, 0, 20);    tty_read(PortFD, test, numReturn + 1, 2, &bytesRead);    LOGF_DEBUG("RES <%s>", test);    if (numReturn > 0)    {        int retval = 0;        retval     = test[0];        if (numReturn > 1)        {            retval = retval << 8;            retval += test[1];        }        if (numReturn > 2)        {            retval = retval << 8;            retval += test[2];        }        return retval;    }    return 0;}
开发者ID:azwing,项目名称:indi,代码行数:48,


示例17: AbortFocuser

bool SestoSenso::AbortFocuser(){    if (isSimulation())        return true;    int nbytes_written;    if (tty_write(PortFD, "#MA!", 4, &nbytes_written) == TTY_OK)    {        FocusAbsPosNP.s = IPS_IDLE;        FocusRelPosNP.s = IPS_IDLE;        IDSetNumber(&FocusAbsPosNP, nullptr);        IDSetNumber(&FocusRelPosNP, nullptr);    }    return isCommandOK("MA");}
开发者ID:rrogge,项目名称:indi,代码行数:16,


示例18: calibrationUnitCommand

/* Construct a command and send it to the spectrograph. It doesn't return * anything so we have to sleep until we know it has flipped the switch. */bool ShelyakEshel::calibrationUnitCommand(char command, char parameter){    int rc, nbytes_written;    char c[5] = { 0x0D, 0x01, command,                  parameter }; // the first 2 bytes are constant, the next 2 are command and parameter    c[4]      = 0x100 - (c[0] + c[1] + c[2] + c[3]) % 0x100; // last byte is is related to the sum of the four first    if ((rc = tty_write(PortFD, c, 5, &nbytes_written)) != TTY_OK) // send the bytes to the spectrograph    {        char errmsg[MAXRBUF];        tty_error_msg(rc, errmsg, MAXRBUF);        LOGF_ERROR("error: %s.", errmsg);        return false;    }    sleep(1); // wait for the calibration unit to actually flip the switch    return true;}
开发者ID:azwing,项目名称:indi,代码行数:19,


示例19: screen_write_clearendofline

/* Clear to end of line from cursor. */voidscreen_write_clearendofline(struct screen_write_ctx *ctx){	struct screen	*s = ctx->s;	struct tty_ctx	 ttyctx;	u_int		 sx;	screen_write_initctx(ctx, &ttyctx, 0);	sx = screen_size_x(s);	if (s->cx <= sx - 1)		grid_view_clear(s->grid, s->cx, s->cy, sx - s->cx, 1);	tty_write(tty_cmd_clearendofline, &ttyctx);}
开发者ID:HonestQiao,项目名称:tmux,代码行数:17,


示例20: abort_ieqpro

bool abort_ieqpro(int fd){    char cmd[] = ":Q#";    int errcode = 0;    char errmsg[MAXRBUF];    char response[8];    int nbytes_read=0;    int nbytes_written=0;    DEBUGFDEVICE(ieqpro_device, INDI::Logger::DBG_DEBUG, "CMD (%s)", cmd);    if (ieqpro_simulation)    {        simInfo.systemStatus = ST_STOPPED;        strcpy(response, "1");        nbytes_read = strlen(response);    }    else    {        if ( (errcode = tty_write(fd, cmd, strlen(cmd), &nbytes_written)) != TTY_OK)        {            tty_error_msg(errcode, errmsg, MAXRBUF);            DEBUGFDEVICE(ieqpro_device, INDI::Logger::DBG_ERROR, "%s", errmsg);            return false;        }        if ( (errcode = tty_read(fd, response, 1, IEQPRO_TIMEOUT, &nbytes_read)))        {            tty_error_msg(errcode, errmsg, MAXRBUF);            DEBUGFDEVICE(ieqpro_device, INDI::Logger::DBG_ERROR, "%s", errmsg);            return false;        }    }    if (nbytes_read > 0)    {      response[nbytes_read] = '/0';      DEBUGFDEVICE(ieqpro_device, INDI::Logger::DBG_DEBUG, "RES (%s)", response);      tcflush(fd, TCIFLUSH);      return true;    }    DEBUGFDEVICE(ieqpro_device, INDI::Logger::DBG_ERROR, "Only received #%d bytes, expected 1.", nbytes_read);    return false;}
开发者ID:daggerstab,项目名称:indi,代码行数:46,


示例21: tty_write_echo

int tty_write_echo(int fd,char byte){	char reply;	if(tty_write(fd,byte)==-1) return(-1);	if(tty_read(fd,&reply)==-1) return(-1);	LOGPRINTF(1,"sent: A%u D%01x reply: A%u D%01x",		  (((unsigned int) (unsigned char) byte)&0xf0)>>4,		  ((unsigned int) (unsigned char) byte)&0x0f,		  (((unsigned int) (unsigned char) reply)&0xf0)>>4,		  ((unsigned int) (unsigned char) reply)&0x0f);	if(byte!=reply)	{		logprintf(LOG_ERR,"Command mismatch.");	}	return(1);}
开发者ID:aldebaran,项目名称:lirc,代码行数:17,


示例22: printk

void printk (const char *fmt, ...){	unsigned long eflags;	static char buffer[1024];	va_list args;	eflags = read_flags ();	cli ();	args = va_start (args, fmt);	vsprintf (buffer, fmt, args);	va_end (args);	tty_write (0, buffer, strlen (buffer));	write_flags (eflags);}
开发者ID:BackupTheBerlios,项目名称:socratix,代码行数:17,


示例23: DEBUG

bool ioptronHC8406::checkConnection(){    if (isSimulation())        return true;    char initCMD[] = ":V#";    int errcode    = 0;    char errmsg[MAXRBUF];    char response[8];    int nbytes_read    = 0;    int nbytes_written = 0;    DEBUG(INDI::Logger::DBG_DEBUG, "Initializing iOptron using :V# CMD...");    for (int i = 0; i < 2; i++)    {        if ((errcode = tty_write(PortFD, initCMD, 3, &nbytes_written)) != TTY_OK)        {            tty_error_msg(errcode, errmsg, MAXRBUF);            DEBUGF(INDI::Logger::DBG_ERROR, "%s", errmsg);            usleep(50000);            continue;        }        if ((errcode = tty_read_section(PortFD, response, '#', 3, &nbytes_read)))        {            tty_error_msg(errcode, errmsg, MAXRBUF);            DEBUGF(INDI::Logger::DBG_ERROR, "%s", errmsg);            usleep(50000);            continue;        }        if (nbytes_read > 0)        {            response[nbytes_read] = '/0';            DEBUGF(INDI::Logger::DBG_DEBUG, "RES (%s)", response);            if (!strcmp(response, "V1.00#"))                return true;        }        usleep(50000);    }    return false;}
开发者ID:rrogge,项目名称:indi,代码行数:46,


示例24: DEBUG

bool SestoSenso::updateTemperature(){    int nbytes_written = 0, nbytes_read = 0, rc = -1;    char errstr[MAXRBUF];    char resp[16]={0};    DEBUG(INDI::Logger::DBG_DEBUG, "CMD <#QT!>");    if (isSimulation())    {        strncpy(resp, "23.45", 16);        nbytes_read = strlen(resp) + 1;    }    else    {        tcflush(PortFD, TCIOFLUSH);        if ((rc = tty_write(PortFD, "#QT!", 4, &nbytes_written)) != TTY_OK)        {            tty_error_msg(rc, errstr, MAXRBUF);            DEBUGF(INDI::Logger::DBG_ERROR, "%s error: %s.", __FUNCTION__, errstr);            TemperatureNP.s = IPS_ALERT;            return false;        }        if ((rc = tty_read_section(PortFD, resp, 0xD, SESTOSENSO_TIMEOUT, &nbytes_read)) != TTY_OK)        {            tty_error_msg(rc, errstr, MAXRBUF);            DEBUGF(INDI::Logger::DBG_ERROR, "%s error: %s.", __FUNCTION__, errstr);            TemperatureNP.s = IPS_ALERT;            return false;        }        tcflush(PortFD, TCIOFLUSH);    }    resp[nbytes_read-1] = '/0';    DEBUGF(INDI::Logger::DBG_DEBUG, "RES <%s>", resp);    TemperatureN[0].value = atof(resp);    TemperatureNP.s = (TemperatureN[0].value == 99.00) ? IPS_IDLE : IPS_OK;    return true;}
开发者ID:rrogge,项目名称:indi,代码行数:45,


示例25: tcflush

IPState FlipFlat::UnParkCap(){    int nbytes_written=0, nbytes_read=0, rc=-1;    char errstr[MAXRBUF];    char command[FLAT_CMD];    char response[FLAT_RES];    tcflush(PortFD, TCIOFLUSH);    strncpy(command, ">O000", FLAT_CMD);    DEBUGF(INDI::Logger::DBG_DEBUG, "CMD (%s)", command);    command[FLAT_CMD-1] = 0xA;    if ( (rc = tty_write(PortFD, command, FLAT_CMD, &nbytes_written)) != TTY_OK)    {        tty_error_msg(rc, errstr, MAXRBUF);        DEBUGF(INDI::Logger::DBG_ERROR, "%s error: %s.", command, errstr);        return IPS_ALERT;    }    if ( (rc = tty_read_section(PortFD, response, 0xA, FLAT_TIMEOUT, &nbytes_read)) != TTY_OK)    {        tty_error_msg(rc, errstr, MAXRBUF);        DEBUGF(INDI::Logger::DBG_ERROR, "%s: %s.", command, errstr);        return IPS_ALERT;    }    response[nbytes_read-1] = '/0';    DEBUGF(INDI::Logger::DBG_DEBUG, "RES (%s)", response);    char expectedResponse[FLAT_RES];    snprintf(expectedResponse, FLAT_RES, "*O%02d000", productID);    if (!strcmp(response, expectedResponse))    {        // Set cover status to random value outside of range to force it to refresh        prevCoverStatus = 10;        return IPS_BUSY;    }    else        return IPS_ALERT;}
开发者ID:A-j-K,项目名称:indi,代码行数:45,


示例26: screen_write_clearstartofline

/* Clear to start of line from cursor. */voidscreen_write_clearstartofline(struct screen_write_ctx *ctx){	struct screen	*s = ctx->s;	struct tty_ctx	 ttyctx;	u_int		 sx;	screen_write_initctx(ctx, &ttyctx);	sx = screen_size_x(s);	if (s->cx > sx - 1)		grid_view_clear(s->grid, 0, s->cy, sx, 1);	else		grid_view_clear(s->grid, 0, s->cy, s->cx + 1, 1);	tty_write(tty_cmd_clearstartofline, &ttyctx);}
开发者ID:7heo,项目名称:tmux,代码行数:19,


示例27: screen_write_clearscreen

/* Clear entire screen. */voidscreen_write_clearscreen(struct screen_write_ctx *ctx){	struct screen	*s = ctx->s;	struct tty_ctx	 ttyctx;	screen_write_initctx(ctx, &ttyctx, 0);	/* Scroll into history if it is enabled. */	if (s->grid->flags & GRID_HISTORY)		grid_view_clear_history(s->grid);	else {		grid_view_clear(		    s->grid, 0, 0, screen_size_x(s), screen_size_y(s));	}	tty_write(tty_cmd_clearscreen, &ttyctx);}
开发者ID:HonestQiao,项目名称:tmux,代码行数:19,


示例28: screen_write_flush

/* Flush outstanding cell writes. */static voidscreen_write_flush(struct screen_write_ctx *ctx){	struct screen	*s = ctx->s;	struct tty_ctx	 ttyctx;	u_int		 x, y, offset, cx, cy, dirty;	struct grid_cell gc;	if (ctx->dirty == 0)		return;	dirty = 0;	log_debug("%s: dirty %u", __func__, ctx->dirty);	cx = s->cx;	cy = s->cy;	offset = 0;	for (y = 0; y < screen_size_y(s); y++) {		for (x = 0; x < screen_size_x(s); x++) {			offset++;			if (!bit_test(s->dirty, offset - 1))				continue;			bit_clear(s->dirty, offset - 1);			screen_write_cursormove(ctx, x, y);			grid_view_get_cell(s->grid, x, y, &gc);			screen_write_initctx(ctx, &ttyctx);			ttyctx.cell = &gc;			tty_write(tty_cmd_cell, &ttyctx);			ctx->written++;			if (++dirty == ctx->dirty)				break;		}		if (dirty == ctx->dirty)			break;	}	ctx->dirty = 0;	s->cx = cx;	s->cy = cy;}
开发者ID:CraZySacX,项目名称:tmux,代码行数:44,


示例29: isSimulation

/************************************************************************************ ** ***********************************************************************************/bool BaaderDome::Ack(){    int nbytes_written = 0, nbytes_read = 0, rc = -1;    char errstr[MAXRBUF];    char resp[DOME_BUF];    char status[DOME_BUF];    sim = isSimulation();    tcflush(PortFD, TCIOFLUSH);    if (!sim && (rc = tty_write(PortFD, "d#getflap", DOME_CMD, &nbytes_written)) != TTY_OK)    {        tty_error_msg(rc, errstr, MAXRBUF);        DEBUGF(INDI::Logger::DBG_ERROR, "d#getflap Ack error: %s.", errstr);        return false;    }    DEBUG(INDI::Logger::DBG_DEBUG, "CMD (d#getflap)");    if (sim)    {        strncpy(resp, "d#flapclo", DOME_BUF);        nbytes_read = DOME_CMD;    }    else if ((rc = tty_read(PortFD, resp, DOME_CMD, DOME_TIMEOUT, &nbytes_read)) != TTY_OK)    {        tty_error_msg(rc, errstr, MAXRBUF);        DEBUGF(INDI::Logger::DBG_ERROR, "Ack error: %s.", errstr);        return false;    }    resp[nbytes_read] = '/0';    DEBUGF(INDI::Logger::DBG_DEBUG, "RES (%s)", resp);    rc = sscanf(resp, "d#%s", status);    if (rc > 0)        return true;    return false;}
开发者ID:rrogge,项目名称:indi,代码行数:46,



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


C++ ttype函数代码示例
C++ tty_wakeup函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。