本文整理汇总了C#中System.IO.Ports.SerialPort.openCOM方法的典型用法代码示例。如果您正苦于以下问题:C# SerialPort.openCOM方法的具体用法?C# SerialPort.openCOM怎么用?C# SerialPort.openCOM使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.IO.Ports.SerialPort
的用法示例。
在下文中一共展示了SerialPort.openCOM方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: initVLC
//.........这里部分代码省略.........
if (!Directory.Exists(curFolder))
{
Directory.CreateDirectory(curFolder);
}
DataUser = Users.read(@"Data\User.mtc");
if (DataUser == null)
{
DataUser = new Users();
User root = new User("root", 1);
root.Pass = "root".toMD5();
root.type = 0;
root.FullName = "Root";
DataUser.Add(root);
Users.write(_FILE_User_Data, DataUser);
}
DataCamera = Cameras.Read(_FILE_Camera_Data);
DataPreset = Presets.Read(_FILE_PRESET_DATA);
DataAlarm = Alarms.Read(_FILE_Alarm_Data);
this.checkFile = new Thread(checkFileFunctionThread);
checkFile.IsBackground = true;
this.checkFile.Start();
#if DEBUG
if (DataCamera.Count == 0)
{
Camera camera = new Camera("192.168.10.199");
camera.name = "Camera Demo";
camera.channel = 1;
camera.port = 8000;
camera.admin = "admin";
camera.pass = "admin";
camera.icon = "fa-video-camera";
DataCamera.Add(camera);
}
if (DataUser.Datas.Count < 2)
{
User root = new User("admin", 2);
root.Pass = "dami".toMD5();
root.type = 1;
root.FullName = "Admin";
DataUser.Add(root);
User root2 = new User("htdm",3);
root2.Pass = "123".toMD5();
root2.type = 2;
root2.FullName = "Camera";
DataUser.Add(root2);
Users.write(_FILE_User_Data, DataUser);
}
#endif
var listCom = getListCOM();
if (listCom.Length > 0)
{
foreach (string i in listCom)
{
try
{
SerialPort serialPort = new SerialPort();
serialPort = new SerialPort();
serialPort.openCOM(i, BAUDRATE, DATABITS, StopBits.One);
serialPort.DataReceived += serialPort_DataReceived;
serialPort.sendCommand("#0$");
listSerialPort.Add(serialPort);
}
catch (Exception)
{
}
}
}
Map = Map.Read(_FILE_Map_Data);
for (int i = 0; i != e.Args.Length; i += 2)
{
if (e.Args[i] == "-u")
{
string hash = e.Args[i + 1];
User u = App.DataUser.Login(hash);
if (u != null)
{
login = false;
App.User = u;
}
}
else if (e.Args[i] == "-mode")
{
Mode = (Camera_Final.Mode)int.Parse(e.Args[i + 1]);
}
}
if (login)
{
this.MainWindow = new Login();
}
else
{
this.MainWindow = new MainWindow();
}
this.MainWindow.Show();
}