我想用RS232线路向我的电子板发送脉冲
我可以使用RTS引脚吗?(之后我的电路板得到脉冲并开始向PC发送数据)
如何在C#中激活此引脚?
提前致谢。
答案 0 :(得分:2)
尝试:
#include <iostream>
using namespace std;
class Vehicle
{
public:
Vehicle(){};
virtual ~Vehicle(){};
virtual int GetItsSpeed() = 0;
int GetItsTyreSize();
virtual int GetItsRegistration() { return ItsRegistration; }
protected:
int ItsSpeed;
int ItsRegistration;
};
class Car : public Vehicle
{
public:
Car(){};
virtual ~Car(){};
virtual int GetItsSpeed() = 0;
int GetItsBootSize() { return ItsBootSize; }
int GetItsRegistration() { return ItsRegistration; }
virtual int GetItsRadioVolume() = 0;
int GetItsTyreSize() { return ItsTyreSize; }
protected:
int ItsBootSize;
int ItsRadioVolume;
int ItsTyreSize;
};
class Bus : public Vehicle
{
Bus(){};
~Bus(){};
public:
int GetItsSpeed() { return ItsSpeed; }
int GetItsPassengerSize() { return ItsPassengerSize; }
private:
int ItsPassengerSize;
};
class SportsCar : public Car
{
public:
SportsCar(){};
~SportsCar(){};
int GetItsSpeed() { return ItsSpeed; }
int GetItsPowerSteeringAccuracy() { return ItsPowerSteeringAccuracy; }
private:
int ItsPowerSteeringAccuracy;
};
class Wagon : public Car
{
public:
Wagon(){};
~Wagon(){};
int GetItsSpeed() { return ItsSpeed; }
int GetItsTrailerSize() { return ItsTrailerSize; }
private:
int ItsTrailerSize;
};
class Coupe : public Car
{
public:
Coupe(){ ItsTyreSize = 10; }
~Coupe(){};
int GetItsSpeed();
int GetItsInteriorStyle() { return ItsInteriorStyle; }
int GetItsRadioVolume() { return ItsRadioVolume; }
private:
int ItsInteriorStyle;
};
void startof()
{
Coupe MariesCoupe;
cout << "Maries Coupe has a tyre size of "
<< MariesCoupe.GetItsTyreSize() << " .\n\n";
}
int main()
{
startof();
return 0;
}
请注意,在打开端口之前,RTS引脚的行为可能是意外的(根据我的经验,它取决于您的硬件,FTDI芯片在初始化时会多次开/关)。
建议使用一些真正的RS232继电器(非常便宜) - 对电压和状态进行全面稳定的控制。