当前位置: 首页>>代码示例>>C++>>正文


C++ BuildCommDCB函数代码示例

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


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

示例1: GetIniCommValues

BOOL
GetIniCommValues(
    _In_ LPWSTR          pName,
         LPDCB          pdcb,
         LPCOMMTIMEOUTS pcto
)
{
    BOOL    bRet        = TRUE;
    LPWSTR  pszEntry    = NULL;


    if (bRet)
    {
        bRet = GetIniCommValuesFromRegistry (pName, &pszEntry);
    }
    if (bRet)
    {
        bRet =  BuildCommDCB (pszEntry, pdcb);
    }
    if (bRet)
    {
        GetTransmissionRetryTimeoutFromRegistry (&pcto-> WriteTotalTimeoutConstant);
        pcto->WriteTotalTimeoutConstant*=1000;
    }
    FreeSplMem(pszEntry);
    return bRet;
}
开发者ID:Realhram,项目名称:wdk81,代码行数:27,代码来源:util.c

示例2: serial_io_init

/** @fn int serial_io_init( const char* port, const char* strsettings )
*****************************************************************************
* @b Description: initialise a serial port communication
*****************************************************************************
* @param      port : port name
*                 example 'COM7'
* @param      strsettings : port settings
*                 example ; 'baud=115200 parity=N data=8 stop=1'
*****************************************************************************
* @return     file descriptor
*             -1 if error
*****************************************************************************
**/
int serial_io_init( const char* port, const char* strsettings )
{
    HANDLE hCom = NULL;

        char strport[16];
        snprintf( strport, sizeof( strport ), "\\\\.\\%s", port );

        hCom = CreateFile(
                        strport,
                        GENERIC_WRITE | GENERIC_READ,
                        0,
                        0,
                        OPEN_EXISTING,
                        0,
                        NULL);

        if (hCom == INVALID_HANDLE_VALUE)
        {
                LPVOID lpMsgBuf;

                FormatMessage(
                        FORMAT_MESSAGE_ALLOCATE_BUFFER |
                        FORMAT_MESSAGE_FROM_SYSTEM |
                        FORMAT_MESSAGE_IGNORE_INSERTS,
                        NULL,
                        GetLastError(),
                        MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
                        (LPTSTR) &lpMsgBuf,
                        0,
                        NULL
                );
                dbg(1, "return (fd) : '-1' : serial_io_init error : '%s'\n", lpMsgBuf);

                LocalFree( lpMsgBuf );       // Free the buffer.
                return -1;
        }

        DCB dcb;

        ZeroMemory(&dcb, sizeof(DCB));

        GetCommState(hCom, &dcb);

        BuildCommDCB( strsettings, &dcb);

        SetupComm(hCom, 4096, 4096);

        SetCommState(hCom, &dcb);

        COMMTIMEOUTS sCT;

        memset(&sCT, 0, sizeof(sCT));
        sCT.ReadTotalTimeoutConstant = 10;

        SetCommTimeouts(hCom, &sCT);

        dbg(1, "serial_io_init return (fd) : '%d'\n", (int)hCom);

   return (int)hCom;
}
开发者ID:justinzane,项目名称:navit,代码行数:73,代码来源:serial_io.c

示例3: setRs232

/*-------------------------------------------
| Name:setRs2322
| Description:
| Parameters:
| Return Type:
| Comments:
| See:
---------------------------------------------*/
int setRs232(uart_config* config){
   COMMCONFIG commconfig;
   DWORD dwSize=sizeof(COMMCONFIG);
   char buffer[256]={0};
   sprintf(buffer,"%s: baud=%d parity=%c data=%d stop=%d",USE_COM,
           config->speed,
           config->parity,
           config->data,
           config->stop);

   if(!GetCommConfig(hCom,&commconfig,&dwSize))
      return -1;

   BuildCommDCB(buffer,&commconfig.dcb);

   //CommConfigDialog(USE_COM,NULL,&commconfig);

   if(!SetCommConfig(hCom,&commconfig,dwSize))
      return -1;

   printf("com cfg: %s\n",buffer);

   memcpy(&current_config,config,sizeof(uart_config));


   return 0;
}
开发者ID:lepton-distribution,项目名称:lepton-root.scions,代码行数:35,代码来源:dev_win32uart.c

示例4: zBuildCommDCB

int far pascal zBuildCommDCB( LPCSTR pp1, DCB far* pp2 )
{
    int r;

    SaveRegs();
    /*
    ** Log IN Parameters (No Create/Destroy Checking Yet!)
    */
    LogIn( (LPSTR)"APICALL:BuildCommDCB ++",
        (short)0, (short)0 );

    /*
    ** Call the API!
    */
    RestoreRegs();
    GrovelDS();
    r = BuildCommDCB(pp1,pp2);
    UnGrovelDS();
    SaveRegs();
    /*
    ** Log Return Code & OUT Parameters (No Create/Destroy Checking Yet!)
    */
    LogOut( (LPSTR)"APIRET:BuildCommDCB int+LPCSTR+DCB far*+",
        r, pp1, pp2 );

    RestoreRegs();
    return( r );
}
开发者ID:mingpen,项目名称:OpenNT,代码行数:28,代码来源:tucomm.c

示例5: initSerial

/**
 * @brief This function initializes the serial port for both directions (reading/writing) with fixed parameters:
 * \n baud=38400, parity=N, data=8, stop=1
 * @param *serialPort is a pointer to the name of the serial port
 * @return TRUE if success, FALSE in case of error.
 */
BOOL initSerial(CHAR *serialPort)
{
	COMMTIMEOUTS timeouts;
	int rc;
	DCB dcbStruct;
	CHAR msgTextBuf[256];

	// open the comm port.
	comPort = CreateFile(serialPort, GENERIC_READ | GENERIC_WRITE, 0, 0, OPEN_EXISTING, 0, NULL);
	if (comPort == INVALID_HANDLE_VALUE)
	{
		printf("Unable to open %s. \n", serialPort);
		return FALSE;
	}

	// get the current DCB, and adjust a few bits to our liking.
	memset(&dcbStruct, 0, sizeof(dcbStruct));

	dcbStruct.DCBlength = sizeof(dcbStruct);
	// printf("dcbStruct.DCBlength(): %ld \n", dcbStruct.DCBlength);

	rc = GetCommState(comPort, &dcbStruct);
	if (rc == 0)
	{
		printf("\nGetCommState(): ");
		printf(getLastErrorText(msgTextBuf, sizeof(msgTextBuf)));
		return FALSE;
	}

	// http://msdn.microsoft.com/en-us/library/windows/desktop/aa363143(v=vs.85).aspx
	BuildCommDCB("baud=38400 parity=N data=8 stop=1", &dcbStruct);

	rc = SetCommState(comPort, &dcbStruct);
	// If the function fails, the return value is zero.
	if (rc == 0)
	{
		printf("\nSetCommState(): ");
		printf(getLastErrorText(msgTextBuf, sizeof(msgTextBuf)));
		return FALSE;
	}

	// Retrieve the timeout parameters for all read and write operations on the port.
	GetCommTimeouts (comPort, &timeouts);

	timeouts.ReadIntervalTimeout = 250;
	timeouts.ReadTotalTimeoutMultiplier = 1;
	timeouts.ReadTotalTimeoutConstant = 500;
	timeouts.WriteTotalTimeoutMultiplier = 1;
	timeouts.WriteTotalTimeoutConstant = 2500;

	rc = SetCommTimeouts(comPort, &timeouts);          // If the function fails, the return value is zero.
	if (rc == 0)
	{
		printf("\nSetCommTimeouts(): ");
		printf(getLastErrorText(msgTextBuf, sizeof(msgTextBuf)));
		return FALSE;
	}

	return TRUE;
}
开发者ID:pszyjaciel,项目名称:myEthernut,代码行数:66,代码来源:mySerial.c

示例6: CreateFile

static SERIALPORT *serial_open(const char *device){
    HANDLE fh;
    DCB dcb={sizeof(DCB)};
    COMMTIMEOUTS timeouts;
    SERIALPORT *port;

    fh = CreateFile(device,GENERIC_READ|GENERIC_WRITE,0,NULL,
      OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL);
    if (!fh) return NULL;

    port = malloc(sizeof(SERIALPORT));
    ZeroMemory(port, sizeof(SERIALPORT));
    port->fh = fh;

    /* save current port settings */
    GetCommState(fh,&port->dcb_save);
    GetCommTimeouts(fh,&port->timeouts_save);

    dcb.DCBlength=sizeof(DCB);
    BuildCommDCB("96,n,8,1",&dcb);
    SetCommState(fh,&dcb);

    ZeroMemory(&timeouts,sizeof(timeouts));
    timeouts.ReadTotalTimeoutConstant=1;
    timeouts.WriteTotalTimeoutConstant=1;
    SetCommTimeouts(fh,&timeouts);

    serial_flush(port);

    return port;
}
开发者ID:meshdgp,项目名称:MeshDGP,代码行数:31,代码来源:freeglut_input_devices.c

示例7: sconfig

// configure serial port
bool sconfig(char* fmt) {
  DCB dcb;
  COMMTIMEOUTS cmt;
  // clear dcb  
  memset(&dcb,0,sizeof(DCB));
  dcb.DCBlength=sizeof(DCB);
  // configure serial parameters
  if(!BuildCommDCB(fmt,&dcb)) return false;
  dcb.fOutxCtsFlow=0;
  dcb.fOutxDsrFlow=0;
  dcb.fDtrControl=0;
  dcb.fOutX=0;
  dcb.fInX=0;
  dcb.fRtsControl=0;
  if(!SetCommState(h_serial,&dcb)) return false;
  // configure buffers
  if(!SetupComm(h_serial,1024,1024)) return false;
  // configure timeouts 
  GetCommTimeouts(h_serial,&cmt);
  memcpy(&restore,&cmt,sizeof(cmt));
  cmt.ReadIntervalTimeout=100;
  cmt.ReadTotalTimeoutMultiplier=100;
  cmt.ReadTotalTimeoutConstant=100;
  cmt.WriteTotalTimeoutConstant=100;
  cmt.WriteTotalTimeoutMultiplier=100;
  if(!SetCommTimeouts(h_serial,&cmt)) return false;
  return true;
}
开发者ID:stg,项目名称:PicOptic,代码行数:29,代码来源:serial.c

示例8: Open

	bool Open(qCtx *ctx, qStr *out, CStr port, CStr dcb_def) {
		DCB dcb;
		HANDLE tCom;
		tCom = CreateFile( port,
			GENERIC_READ | GENERIC_WRITE,
			0,    // comm devices must be opened w/exclusive-access 
			NULL, // no security attributes 
			OPEN_EXISTING, // comm devices must use OPEN_EXISTING 
			0,    // not overlapped I/O 
			NULL  // hTemplate must be NULL for comm devices 
			);

		if (tCom == INVALID_HANDLE_VALUE) {
			ctx->ThrowF(out, 601, "Invalid comm port. %y", GetLastError());
			return false;
		}

		GetCommState(tCom, &dcb);

		if (!dcb_def.IsEmpty() && 
				(!BuildCommDCB(dcb_def, &dcb) || !SetCommState(tCom, &dcb))
			) {
			ctx->ThrowF(out, 602, "Invalid comm definition parameter(s). %y", GetLastError());
			return false;
		}

		myCom = tCom;
		return true;
	}
开发者ID:BackupTheBerlios,项目名称:smx-svn,代码行数:29,代码来源:io.cpp

示例9: serial_params

// configures port from string of format
//   baudrate,parity,databits,stopbits
// example
//   9600,n,8,1
int serial_params( char* params ) {
	DCB dcb;
	COMMTIMEOUTS cmt;

	memset( &dcb, 0, sizeof( DCB ) );
	dcb.DCBlength = sizeof( DCB );

	// Configure serial parameters
	//printf( "BuildCommDCB\n" );
	if( !BuildCommDCB( params, &dcb ) ) return( -1 );
	//printf( "SetCommState\n" );
	dcb.fOutxCtsFlow = 0;
	dcb.fOutxDsrFlow = 0;
	dcb.fDtrControl = 0;
	dcb.fOutX = 0;
	dcb.fInX = 0;
	dcb.fRtsControl = 0;

	if( !SetCommState( h_serial, &dcb ) ) return( -1 );

	// Configure buffers
	//printf( "SetupComm\n" );
	if( !SetupComm( h_serial,	1024,	1024) ) return( -1 );

	// Configure timeouts	
	cmt.ReadIntervalTimeout = 1000;
	cmt.ReadTotalTimeoutMultiplier = 1000;
	cmt.ReadTotalTimeoutConstant = 1000;
	cmt.WriteTotalTimeoutConstant = 1000;
	cmt.WriteTotalTimeoutMultiplier = 1000;
	if( !SetCommTimeouts( h_serial, &cmt ) ) return( -1 );

	return( 0 );
}
开发者ID:MITRoboOps,项目名称:2014Software,代码行数:38,代码来源:oswrap.c

示例10: CreateFile

bool CSerialPort::Open( LPCTSTR lpszComPort,LPCTSTR lpszConString ,int delay_us)
{
	CString sPort;
	sPort.Format(_T("\\\\.\\%s"), lpszComPort);

	m_hComm = CreateFile(sPort,  GENERIC_READ | GENERIC_WRITE, 0, 0, OPEN_EXISTING,0,0);
	if (m_hComm == INVALID_HANDLE_VALUE)
	{
		CString str;
		GetErrorStr(str);
		LogMessage(str);
		return false;
	}
	Delay_US = delay_us;
	// Set Com Settings
	DCB dcb;
	FillMemory(&dcb, sizeof(dcb), 0);
	dcb.DCBlength = sizeof(dcb);
	if (!BuildCommDCB(lpszConString, &dcb))
	{   
		// Couldn't build the DCB. Usually a problem
		// with the communications specification string.
		CString str;
		GetErrorStr(str);
		LogMessage(str);
		LogMessage("Seri Port Hatasý. (BuildComDCB)");		
		CloseHandle(m_hComm);
		m_hComm = NULL;
		return false;
	}
	if (!SetCommState(m_hComm, &dcb))
	{
		CString str;
		GetErrorStr(str);
		LogMessage(str);
		LogMessage("Seri Port Hatasý. (SetCommState)");
		CloseHandle(m_hComm);
		m_hComm = NULL;
		return false;
	}
	COMMTIMEOUTS cm;
	FillMemory(&cm, sizeof(cm), 0);
	cm.ReadIntervalTimeout = 10;
	cm.ReadTotalTimeoutConstant = 10;
	if(!SetCommTimeouts(m_hComm,&cm))
	{
		CString str;
		GetErrorStr(str);
		LogMessage(str);
		LogMessage("Seri Port Hatasý. (SetCommTimeouts)");
		CloseHandle(m_hComm);
		m_hComm = NULL;
		return false;
	}	
	LogMessage("Seri port açýldý.");
	return true;
}
开发者ID:hozgur,项目名称:Colorway,代码行数:57,代码来源:SerialPort.cpp

示例11: open_com_port

//------------------------------------------------------------------------------
bool open_com_port( HANDLE &hCOM_HANDLE, int i_com_port, int i_baud_rate)
{
    if ( hCOM_HANDLE != NULL && hCOM_HANDLE != INVALID_HANDLE_VALUE )
    {
        PurgeComm( hCOM_HANDLE, PURGE_TXABORT);
        PurgeComm( hCOM_HANDLE, PURGE_RXABORT);
        PurgeComm( hCOM_HANDLE, PURGE_TXCLEAR);
        PurgeComm( hCOM_HANDLE, PURGE_RXCLEAR);
        CloseHandle( hCOM_HANDLE);
        hCOM_HANDLE = NULL;
    }

	char c_com[50];

    ::sprintf(c_com, "\\\\.\\COM%d", i_com_port);

	hCOM_HANDLE = ::CreateFile( c_com,
			                    GENERIC_READ|GENERIC_WRITE,
			                    0,
			                    NULL,
			                    OPEN_EXISTING,
			                    FILE_ATTRIBUTE_NORMAL,
			                    NULL);

	if( hCOM_HANDLE == INVALID_HANDLE_VALUE )
    {
        //ShowMessage(" COM" + IntToStr( i_com_port) + " is used by other program.");
		GC_TRACE("<EfuseWriter> open_com_port(): Com %d is used by other program", i_com_port);
        hCOM_HANDLE = NULL;
	    return false;
	}

	if( ::SetupComm(hCOM_HANDLE, 8192, 8192)==FALSE )
        return false;

	if( ::PurgeComm(hCOM_HANDLE, PURGE_TXABORT|PURGE_RXABORT|PURGE_TXCLEAR|PURGE_RXCLEAR)==FALSE )
        return false;


    COMMTIMEOUTS TimeOut;
    TimeOut.ReadIntervalTimeout         = 0;
    TimeOut.ReadTotalTimeoutMultiplier  = 1;
    TimeOut.ReadTotalTimeoutConstant    = 700;
    TimeOut.WriteTotalTimeoutMultiplier = 1;
    TimeOut.WriteTotalTimeoutConstant   = 700;

    SetCommTimeouts(hCOM_HANDLE, &TimeOut);

	char c_dcb[50];
    ::sprintf( c_dcb, "%d,n,8,1", i_baud_rate);

    BuildCommDCB( c_dcb, &dcb );

    SetCommState( hCOM_HANDLE, &dcb );
    return true;
}
开发者ID:iamtag,项目名称:sp_mdt,代码行数:57,代码来源:com_util.cpp

示例12: openCOMPort

void openCOMPort(int port)
{
	char portString[100];
	sprintf(portString, "\\\\.\\COM%i", port);
	hComm = CreateFile(portString, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, NULL, 0);
	if (hComm == INVALID_HANDLE_VALUE) {
		printf("port open error\n");
		exit(1);
	}
	COMMTIMEOUTS commTimeouts;
	commTimeouts.ReadIntervalTimeout = MAXDWORD;
	commTimeouts.ReadTotalTimeoutMultiplier = MAXDWORD ;
	commTimeouts.ReadTotalTimeoutConstant = 1;
	commTimeouts.WriteTotalTimeoutMultiplier = 1000;
	commTimeouts.WriteTotalTimeoutConstant = 1000;
	if (!SetCommTimeouts(hComm, &commTimeouts)) {						   
		printf("SetCommTimeouts error\n");
		exit(1);
	}
	DCB	dcb;
	if (!GetCommState(hComm, &dcb)) {
		printf("GetCommState error\n");
		exit(1);
	}
	if (!BuildCommDCB("baud=115200 parity=N data=8 stop=1", &dcb)) {
		printf("BuildCommDCB() error\n");
		exit(1);
	}
	dcb.BaudRate = CBR_115200;
	dcb.fBinary = TRUE;
	dcb.fParity = FALSE;
	dcb.fOutxCtsFlow = FALSE;
	dcb.fOutxDsrFlow = FALSE;
	dcb.fDtrControl = DTR_CONTROL_DISABLE;
	dcb.fDsrSensitivity = FALSE;
	dcb.fOutX = FALSE;
	dcb.fInX = FALSE;
	dcb.fErrorChar = FALSE;
	dcb.fNull = FALSE;
	dcb.fRtsControl = RTS_CONTROL_DISABLE;
	dcb.fAbortOnError = FALSE;
	dcb.ByteSize = 8;
	dcb.Parity = NOPARITY;
	dcb.StopBits = ONESTOPBIT;
	if (!SetCommState(hComm, &dcb)) {
		printf("SetCommState() error\n");
		exit(1);
	}
	PurgeComm(hComm, PURGE_RXCLEAR | PURGE_TXCLEAR | PURGE_RXABORT | PURGE_TXABORT);
	DWORD threadID;
	HANDLE thread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE) commThread, NULL, 0, &threadID);
	if (!thread) {
		printf("CreateThread() error\n");
		exit(1);
	}
}
开发者ID:FrankBuss,项目名称:YaGraphCon,代码行数:56,代码来源:serial.cpp

示例13: PrnOpen

BOOL PrnOpen(PCHAR DevName)
{
	char Temp[MAXPATHLEN], *c;
	DCB dcb;
	DWORD DErr;
	COMMTIMEOUTS ctmo;
	OSVERSIONINFO osvi;

	strncpy_s(Temp, sizeof(Temp),DevName, _TRUNCATE);
	c = Temp;
	while (*c != '\0' && *c != ':') {
		c++;
	}
	*c = '\0';
	LPTFlag = (Temp[0]=='L') ||
	          (Temp[0]=='l');

	osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
	GetVersionEx(&osvi);
	if (osvi.dwPlatformId == VER_PLATFORM_WIN32_NT) {
		// ネットワーク共有にマップされたデバイスが相手の場合、こうしないといけないらしい (2011.01.25 maya)
		// http://logmett.com/forum/viewtopic.php?f=2&t=1383
		// http://msdn.microsoft.com/en-us/library/aa363858(v=vs.85).aspx#5
		PrnID = CreateFile(Temp,GENERIC_WRITE | FILE_READ_ATTRIBUTES,
		                   FILE_SHARE_READ,NULL,CREATE_ALWAYS,
		                   0,NULL);
	}
	else {
		// 9x では上記のコードでうまくいかないので従来通りの処理
		PrnID = CreateFile(Temp,GENERIC_WRITE,
		                   0,NULL,OPEN_EXISTING,
		                   0,NULL);
	}

	if (PrnID == INVALID_HANDLE_VALUE) {
		return FALSE;
	}

	if (GetCommState(PrnID,&dcb)) {
		BuildCommDCB(DevName,&dcb);
		SetCommState(PrnID,&dcb);
	}
	ClearCommError(PrnID,&DErr,NULL);
	if (! LPTFlag) {
		SetupComm(PrnID,0,CommOutQueSize);
	}
	/* flush output buffer */
	PurgeComm(PrnID, PURGE_TXABORT | PURGE_TXCLEAR);
	memset(&ctmo,0,sizeof(ctmo));
	ctmo.WriteTotalTimeoutConstant = 1000;
	SetCommTimeouts(PrnID,&ctmo);
	if (! LPTFlag) {
		EscapeCommFunction(PrnID,SETDTR);
	}
	return TRUE;
}
开发者ID:pakls,项目名称:teraterm-ttssh2,代码行数:56,代码来源:commlib.c

示例14: SerialInit

static const char * SerialInit(struct serial *sn, const char *Device,
enum SerialBaud Baud, enum SerialStopbits StopBits,
enum SerialProtocol Protocol, enum SerialParity Parity,
enum SerialDatabits DataBits, int dowrite)
{
  char mydevice[50];
  if(Device[0] != '\\')
    snprintf(mydevice, sizeof(mydevice), "\\\\.\\%s", Device);
  else
    mydevice[0] = 0;

  if((sn->Stream = CreateFile(mydevice[0] ? mydevice : Device,
  dowrite ? GENERIC_WRITE|GENERIC_READ : GENERIC_READ, 0, 0, OPEN_EXISTING,
  0, 0)) == INVALID_HANDLE_VALUE)
    return "could not create file";

  memset(&sn->Termios, 0, sizeof(sn->Termios));
  GetCommState(sn->Stream, &sn->Termios);

  DCB dcb;
  memset(&dcb, 0, sizeof(dcb));
  char str[100];
  snprintf(str,sizeof(str),
  "baud=%d parity=%c data=%d stop=%d xon=%s octs=%s rts=%s",
  Baud, Parity, DataBits, StopBits,
  Protocol == SPAPROTOCOL_XON_XOFF ? "on" : "off",
  Protocol == SPAPROTOCOL_RTS_CTS ? "on" : "off",
  Protocol == SPAPROTOCOL_RTS_CTS ? "on" : "off");
#ifdef DEBUG
  fprintf(stderr, "COM Settings: %s\n", str);
#endif

  COMMTIMEOUTS ct = {MAXDWORD, 0, 0, 0, 0};

  if(!BuildCommDCB(str, &dcb))
  {
    CloseHandle(sn->Stream);
    return "creating device parameters failed";
  }
  else if(!SetCommState(sn->Stream, &dcb))
  {
    CloseHandle(sn->Stream);
    return "setting device parameters failed";
  }
  else if(!SetCommTimeouts(sn->Stream, &ct))
  {
    CloseHandle(sn->Stream);
    return "setting timeouts failed";
  }

  return 0;
}
开发者ID:7890,项目名称:ntripclient,代码行数:52,代码来源:serial.c

示例15: sscanf

void CUartChannel::SetupBaud(char *setting)
{
	DCB dcb;

	sscanf(setting, "%d", &this->m_baud);
	if(this->IsOpened() == FALSE)
		return;
	memset( &dcb, 0, sizeof(DCB) );
	dcb.DCBlength = sizeof(DCB);
	if (!BuildCommDCB(setting, &dcb))    
		return;
	SetCommState(this->m_Hcomm, &dcb);
}
开发者ID:stormbay,项目名称:DragonVer1.0,代码行数:13,代码来源:UartChannel.cpp


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