You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
60 lines
1.5 KiB
60 lines
1.5 KiB
2 years ago
|
namespace EC.Util.Port;
|
||
|
|
||
|
/// <summary>
|
||
|
/// 串口构建类
|
||
|
/// </summary>
|
||
|
public class SerialPortBuilder
|
||
|
{
|
||
|
/// <summary>
|
||
|
/// </summary>
|
||
|
/// <param name="param"></param>
|
||
|
/// <returns></returns>
|
||
|
public static YcSerialPort CreateSerialPort(SerialPortParam param)
|
||
|
{
|
||
|
return new YcSerialPort(param);
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// </summary>
|
||
|
/// <param name="comName"></param>
|
||
|
public static YcSerialPort CreateSerialPort(string comName)
|
||
|
{
|
||
|
var param = new SerialPortParam
|
||
|
{
|
||
|
ComName = comName
|
||
|
};
|
||
|
return new YcSerialPort(param);
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// </summary>
|
||
|
/// <param name="comName"></param>
|
||
|
/// <param name="baudRate"></param>
|
||
|
/// <returns></returns>
|
||
|
public static YcSerialPort CreateSerialPort(string comName, int baudRate)
|
||
|
{
|
||
|
var param = new SerialPortParam
|
||
|
{
|
||
|
ComName = comName,
|
||
|
BaudRate = baudRate
|
||
|
};
|
||
|
return new YcSerialPort(param);
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// </summary>
|
||
|
/// <param name="comName"></param>
|
||
|
/// <param name="baudRate"></param>
|
||
|
/// <param name="receivedBytesThreshold"></param>
|
||
|
/// <returns></returns>
|
||
|
public static YcSerialPort CreateSerialPort(string comName, int baudRate, int receivedBytesThreshold)
|
||
|
{
|
||
|
var param = new SerialPortParam
|
||
|
{
|
||
|
ComName = comName,
|
||
|
BaudRate = baudRate,
|
||
|
ReceivedBytesThreshold = receivedBytesThreshold
|
||
|
};
|
||
|
return new YcSerialPort(param);
|
||
|
}
|
||
|
}
|