Fix Systec scale
This commit is contained in:
@ -23,11 +23,11 @@ namespace Elwig.Helpers {
|
||||
[GeneratedRegex("^serial://([A-Za-z0-9]+):([0-9]+)(,([5-9]),([NOEMSnoems]),(0|1|1\\.5|2|))?$", RegexOptions.Compiled)]
|
||||
private static partial Regex GeneratedSerialRegex();
|
||||
|
||||
[GeneratedRegex("^tcp://[A-Za-z0-9:._-]+(:[0-9]+)?$", RegexOptions.Compiled)]
|
||||
[GeneratedRegex("^tcp://([A-Za-z0-9._-]+):([0-9]+)$", RegexOptions.Compiled)]
|
||||
private static partial Regex GeneratedTcpRegex();
|
||||
|
||||
public static SerialPort OpenSerialConnection(string connection) {
|
||||
var m = Utils.SerialRegex.Match(connection);
|
||||
var m = SerialRegex.Match(connection);
|
||||
if (!m.Success)
|
||||
throw new ArgumentException("Invalid connection string for scheme \"serial\"");
|
||||
|
||||
@ -45,19 +45,21 @@ namespace Elwig.Helpers {
|
||||
DataBits = data == "" ? 8 : int.Parse(data),
|
||||
StopBits = (StopBits)(stop == "" ? 1 : stop == "1.5" ? 3 : stop[0] - '0'),
|
||||
Handshake = Handshake.None,
|
||||
ReadTimeout = 1000,
|
||||
WriteTimeout = 1000,
|
||||
};
|
||||
port.Open();
|
||||
return port;
|
||||
}
|
||||
|
||||
public static TcpClient OpenTcpConnection(string connection) {
|
||||
var m = Utils.TcpRegex.Match(connection);
|
||||
var m = TcpRegex.Match(connection);
|
||||
if (!m.Success)
|
||||
throw new ArgumentException("Invalid connection string for scheme \"tcp\"");
|
||||
|
||||
var client = new TcpClient() {
|
||||
SendTimeout = 250,
|
||||
ReceiveTimeout = 250,
|
||||
SendTimeout = 1000,
|
||||
ReceiveTimeout = 1000,
|
||||
};
|
||||
client.Connect(m.Groups[1].Value, int.Parse(m.Groups[2].Value));
|
||||
return client;
|
||||
|
Reference in New Issue
Block a user