如何將控制指令傳入SSC-32
現在知道SSC-32的一些控制指令,但是不知道如何將指令傳到SSC-32 用RS232接一條com的傳輸線到它上面
不管用任何程式都能傳遞控制字串上去了
如果真的不懂, 建議先去買本RS232控制相關的書先看喔 這是用c#寫的
按button1就會動
public Form1()
{
InitializeComponent();
if (serialPort.IsOpen)
{
serialPort.Close();
}
// Configure our serial port *** You'll likely need to change these for your config! ***
serialPort.PortName = "COM1";
serialPort.BaudRate = 115200;
serialPort.Parity = System.IO.Ports.Parity.None;
serialPort.DataBits = 8;
serialPort.StopBits = System.IO.Ports.StopBits.One;
}
private void checkBox1_CheckedChanged(object sender, EventArgs e)
{
if (checkBox1.Checked == true)
{
System.Console.Beep(168, 114);
serialPort.Open();
serialPort.Write("#0 P1800\r");
serialPort.Write("#1 P1800\r");
}
else
{
System.Console.Beep(48, 54);
serialPort.Close();
}
}
private void button1_Click(object sender, EventArgs e)
{
serialPort.Write("#1 P1450\r");
} 請問vegewell:
我將您的程式語言不多不少、一字不漏的寫在編輯器上,但是在
第一行的Form1、第16和第32行的void 出現如下的錯誤描述:
必須是類別、委派、列舉、介面或結構
該如何修改?
另外,您說的 button1 是指哪個按鍵?
註:我用的是 Microsoft Visual C# 2008 Express 版 那個不能這樣貼
開個全新的專案
畫面空白處點兩下
貼這段
InitializeComponent();
if (serialPort.IsOpen)
{
serialPort.Close();
}
// Configure our serial port *** You'll likely need to change these for your config! ***
serialPort.PortName = "COM1";
serialPort.BaudRate = 115200;
serialPort.Parity = System.IO.Ports.Parity.None;
serialPort.DataBits = 8;
serialPort.StopBits = System.IO.Ports.StopBits.One;
拉個按鈕, 點兩下, 貼這段
serialPort.Write("#1 P1450\r"); 不過, 看你的回答, 似乎不會C#?
他另外要在畫面上拉個serial port物件
不然就得要動態產生
System.IO.Ports.SerialPort serialPort =new SerialPort( );
一樣加在第一段的第一行 我寫成
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO.Ports;
namespace ConsoleApplication1
{
class Program
{
System.IO.Ports.SerialPort serialPort = new SerialPort();
public void Form1()
{
InitializeComponent();
if (serialPort.IsOpen)
{
serialPort.Close();
}
// Configure our serial port *** You'll likely need to change these for your config! ***
serialPort.PortName = "COM1";
serialPort.BaudRate = 115200;
serialPort.Parity = System.IO.Ports.Parity.None;
serialPort.DataBits = 8;
serialPort.StopBits = System.IO.Ports.StopBits.One;
}
private void InitializeComponent()
{
throw new NotImplementedException();
}
private void button1_Click(object sender, EventArgs e)
{
serialPort.Write("#1 P1450\r");
}
}
}
出現錯誤:未包含適合做為進入點的靜態'Main'方法
請問如何修改? 專案型態錯誤
你一定選到ConsoleApplication1 (主控台應用程式)
開新的專案, 選擇"windows 應用程式"吧
VS .net 的專案型態有很多種
每一種的作法都不太一樣哩
如果是要寫成主控台應用程式也是可以 , 只是整個流程會很難看
都在那個黑媽媽的console畫面下執行
頁:
[1]