tengmo535 发表于 2011-4-11 20:10:46

串口 ACE_Asynch_Write_Stream::write()总是返回 -1 ?!

本帖最后由 tengmo535 于 2011-4-11 20:17 编辑

void CMyServer::open (ACE_HANDLE handle,ACE_Message_Block &message_block)
{
        if (this->rs_.open (*this, handle) == -1)//||this->wr_.open(*this,handle)==-1)
        {
                return;
        }
        if (this->wr_.open(*this,handle)==-1)
        {
                return;
        }

        BYTE sendBuf={'D','H',11,0x41,0x00,0x00,0,0,0,0,200};
        ACE_Message_Block* mb = new ACE_Message_Block((char*)sendBuf,sendBuf);
        mb->wr_ptr(sendBuf);        
        if(wr_.write(*mb,mb->length())==-1)   //此处总是返回 -1,大概什么原因?(写向串口,从串口读很正常)
        {
                mb->release();
        }

               ……

}

tengmo535 发表于 2011-4-12 14:36:09

这个我自己找到答案了。ACE的底层write用的是WSASend,向串口写需改成WriteFile.
目前write的问题解决了,但程序又不响应read的handle_event()了
页: [1]
查看完整版本: 串口 ACE_Asynch_Write_Stream::write()总是返回 -1 ?!