-
-
[求助]设置串口第九位(地址位)不成功
-
发表于:
2007-3-14 16:55
4776
-
m_SerialPort.Open(1);
DCB dcb;
dcb.DCBlength = sizeof(DCB);
//改变地址位为1
dcb.Parity = MARKPARITY:
m_SerialPort.SetState(dcb);
//传送设备地址符(DeviceAddress为一设备地址位)
m_SerialPort.TransmitChar(DeviceAddress);
//改变地址位为0
dcb.Parity = SPACEPARITY;
m_SerialPort.SetState(dcb);
//传送设备状态
CString strDeviceState(_T(""));
for(int nItemIndex=0;nItemIndex<10;nItemIndex++)
{
strDeviceState.AppendChar(nItemIndex);//灯索引
strDeviceState.AppendChar(TRUE); //灯状态
}
strDeviceState.AppendChar(FinshTag); //完成标志
m_SerialPort.Write(strDeviceState.GetBuffer(),strDeviceState.GetLength());
[培训]内核驱动高级班,冲击BAT一流互联网大厂工作,每周日13:00-18:00直播授课