I need to remotely control a servo and have chosen Visual Studio .NET to do so. A website will take simple input from the user then transmit that information via the serial port to the servo. No feedback is needed--I just need to send a number 0 thru 10.
I am having trouble opening the serial port for communication. I keep getting the error
"c:\inetpub\wwwroot\TestApp\Start_r2.aspx.cs(57): The type or namespace name 'HANDLE' could not be found (are you missing a using directive or an assembly reference?)"
Here is my code:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.IO.IsolatedStorage;namespace TestApp
{
/// <summary>
/// Summary description for WebForm1.
/// </summary>
public class WebForm1 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.TextBox TextBox1;
protected System.Web.UI.WebControls.Button Button1;private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
}#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.Button1.Click += new System.EventHandler(this.Button1_Click);
this.Load += new System.EventHandler(this.Page_Load);}
#endregionprivate void Button1_Click(object sender, System.EventArgs e)
{
TextBox1.Text = "Input Speed here (0-10)";
{
//Open serial port for write operation
}HANDLE hComm;
CreateFile( gszPort,
GENERIC_READ | GENERIC_WRITE,
0,
0,
OPEN_EXISTING,
FILE_FLAG_OVERLAPPED,
0);
//if (hcomm == INVALID_HANDLE_VALUE)}
}
}
PLEASE HELP!Did you have any luck with this as I am trying to do a similar thing???
thanks
private void Button1_Click(object sender, System.EventArgs e)
{
TextBox1.Text = "Input Speed here (0-10)";
{
//Open serial port for write operation
}
I think you need a handler after (object sender, System.EventArgs e) Handles Button1.Click
I'm really not sure as I don't code in C#
0 comments:
Post a Comment