資源簡介
51單片機8路高精度舵機下位機及C#上位機程序

代碼片段和文件信息
using?System;
using?System.Collections.Generic;
using?System.ComponentModel;
using?System.Data;
using?System.Drawing;
using?System.Linq;
using?System.Text;
using?System.Windows.Forms;
using?System.Net;
using?System.Net.Sockets;
using?System.IO;
using?Microsoft.Win32;
using?System.Runtime.InteropServices;
namespace?WifiVideo
{
????public?partial?class?Form1?:?Form
????{
????????public?Form1()
????????{
????????????InitializeComponent();
????????}
????????//聲明讀寫INI文件的API函數
????????[DllImport(“kernel32“)]
????????private?static?extern?bool?WritePrivateProfileString(string?section?string?key?string?val?string?filePath);
????????[DllImport(“kernel32“)]
????????private?static?extern?int?GetPrivateProfileString(string?section?string?key?string?def?byte[]?retVal?int?size?string?filePath);
????????static?string?FileName?=?(Application.StartupPath?+?@“\Config.ini“);
????????public?string?ReadIni(string?Section?string?Ident?string?Default)
????????{
????????????Byte[]?Buffer?=?new?Byte[65535];
????????????int?bufLen?=?GetPrivateProfileString(Section?Ident?Default?Buffer?Buffer.GetUpperBound(0)?FileName);
????????????string?s?=?Encoding.GetEncoding(0).GetString(Buffer);
????????????s?=?s.Substring(0?bufLen);
????????????return?s.Trim();
????????}
????????string?CameraIp?=?““;
????????string?ControlIp?=?“192.168.1.1“;
????????string?Port?=?“81“;
????????string?CMD_Servo1_1?=?““?CMD_Servo1_2?=?““;
????????string?CMD_Servo2_1?=?““?CMD_Servo2_2?=?““;
????????string?CMD_Servo3_1?=?““?CMD_Servo3_2?=?““;
????????string?CMD_Servo4_1?=?““?CMD_Servo4_2?=?““;
????????string?CMD_Servo5_1?=?““?CMD_Servo5_2?=?““;
????????string?CMD_Servo6_1?=?““?CMD_Servo6_2?=?““;
????????Socket?socket?=?null;
????????private?void?timer1_Tick(object?sender?EventArgs?e)
????????{
????????????pictureBox1.ImageLocation?=?CameraIp;//?“http://192.168.1.1:8080/?action=snapshot“;
????????}
????????void?SendData(char?char1?char?char2)
????????{
?????????????try
????????????{
????????????????label2.Text?=?Convert.ToInt16(char1)?+?““?+?Convert.ToInt16(char2);
????????????????byte[]?bs?=?{?Convert.ToByte(char1)?Convert.ToByte(char2)?};//Encoding.ASCII?是得不到8位ASCII碼的
????????????????socket.Send(bs?bs.Length?0);//發送測試信息
????????????}
?????????????catch?(Exception?ec)
?????????????{
?????????????????MessageBox.Show(ec.Message);
?????????????}
????????}
????????private?void?Form1_Load(object?sender?EventArgs?e)
????????{
????????????GetIni();
????????????try
????????????{
????????????????IPAddress?ips?=?IPAddress.Parse(ControlIp.ToString());//(“192.168.2.1“);
????????????????IPEndPoint?ipe?=?new?IPEndPoint(ips?Convert.ToInt32(Port.ToString()));//把ip和端口轉化為IPEndPoint實例
????????????????socket?=?new?Socket(AddressFamily.InterNetwork?SocketType.Stream?ProtocolType.Tcp);//創建一個Socket
????????????????socket.Connect(ipe);//連接到服務器
????????????}
????????????catch?(Exception?ec)
????????????{
???????
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2012-02-19?23:28??Debug\
?????文件?????????466??2012-01-04?21:50??Debug\Config.ini
?????文件????????1627??2012-01-05?21:26??Debug\WifiVideo.application
?????文件???????25600??2012-01-05?21:26??Debug\WifiVideo.exe
?????文件????????3633??2012-01-05?21:26??Debug\WifiVideo.exe.manifest
?????文件???????44544??2012-01-05?21:26??Debug\WifiVideo.pdb
?????文件????????1627??2012-01-05?21:26??Debug\WifiVideo.vshost.application
?????文件???????11608??2012-01-05?21:27??Debug\WifiVideo.vshost.exe
?????文件????????3633??2012-01-05?21:26??Debug\WifiVideo.vshost.exe.manifest
?????文件????????3417??2012-02-17?22:04??串口收發.hex
?????文件????????5393??2012-02-17?22:04??串口收發.c
?????文件????????7721??2012-01-08?23:40??Form1.cs
- 上一篇:高斯正反算C#實現
- 下一篇:基于keras多層LSTM實現數據集
評論
共有 條評論