#include <afxwin.h>
#include "iostream.h"
#include "string.h"
#include "mscomm.h"class RTS {
public:
CMSComm com1;
void initialize();
void setRTSTrue(BOOL value,double openSeconds);
void setRTSFalse(BOOL value);
BOOL getRTS();
void closePort();
};void RTS::initialize()
{
com1.SetCommPort(1);
com1.SetSettings("9600,N,8,1");
com1.SetInputLen(1);
com1.SetPortOpen(true);
}void RTS::setRTSTrue(BOOL value, double openSeconds) {
com1.SetRTSEnable(value);
// Sleep((double)(openSeconds*1000));
}void RTS::setRTSFalse(BOOL value) {
com1.SetRTSEnable(value);
}BOOL RTS::getRTS() {
return com1.GetRTSEnable();
}void RTS::closePort() {
com1.SetPortOpen(false);
}
int main(){
RTS rtsTest;
rtsTest.initialize();
cout << ("rtsTest.initialize();");
rtsTest.setRTSTrue(true, 0.5);
rtsTest.setRTSFalse(false);
rtsTest.closePort();
cout << (rtsTest.getRTS());
return 0;
}
这是一个调用MSComm控件的一个类,很简单,为什么没有结果出来?