-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWEATHERSTATION.cs
44 lines (40 loc) · 1.24 KB
/
WEATHERSTATION.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
using System;
using System.Collections.Generic;
using System.Text;
using System.IO.Ports;
namespace WS2300
{
class WEATHERSTATION : System.IO.Ports.SerialPort
{
const int BAUDRATE = 2400;
const string DEFAULT_SERIAL_DEVICE = "COM1";
public WEATHERSTATION(String port)
{
if (port.Trim().Length == 0) port = DEFAULT_SERIAL_DEVICE;
base.PortName = port;
base.BaudRate = BAUDRATE;
base.DtrEnable = false;
base.RtsEnable = true;
base.DataBits = 8;
base.Parity = Parity.None;
base.Handshake = Handshake.None;
base.ReadTimeout = 175;
base.WriteTimeout = 175;
base.Open();
}
public string status()
{
string str = "CLOSED";
if (base.IsOpen)
{
str = base.PortName.ToString();
str += ": " + base.BaudRate.ToString();
str += "," + base.Parity.ToString().Substring(0, 1);
str += "," + base.DataBits.ToString();
str += "," + base.StopBits.ToString();
str += " HndShk:" + base.Handshake.ToString();
}
return str;
}
}
}