Hi,
I have problem. I want to react on event which come from IO.Port(RS232). I
have a class that works on console application
class Program
{
static void Main(string[] args)
{
SerialPortProgram s = new SerialPortProgram();
}
internal static void Run()
{
while(true)
// do nothing
}
}
class SerialPortProgram
{
private SerialPort port = new SerialPort("COM1", 9600, Parity.None, 8,
StopBits.One);
public SerialPortProgram()
{
string text1 = "A";
Console.WriteLine("Incoming Data:");
port.DataReceived += new SerialDataReceivedEventHandler(port_DataReceived);
port.Open();
WriteToPort(text1);
Program.Run(); // ---- the thread is running so I could recive data from
IO.Port ----
}
[STAThread]
public int WriteToPort(string s)
{
port.Write(s);
return 1;
}
public void ClosePort()
{
port.Close();
}
private void port_DataReceived(object sender, SerialDataReceivedEventArgs e)
{
Console.WriteLine(port.ReadExisting());
}
}
[STAThread]
public int WriteToPort(string s)
{
port.Write(s);
return 1;
}
public void ClosePort()
{
port.Close();
}
private void port_DataReceived(object sender, SerialDataReceivedEventArgs e)
{
Console.WriteLine(port.ReadExisting());
}
}
And I don't know how to display recived data from the
port(port.ReadExisting()) for egzample in asp:TextBox.
Can anyone help me?
Thanks for any insight,
Maciek 5 1803
Where is the port you want to read from, on the client or on the server?
--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET] http://msmvps.com/blogs/egoldin http://usableasp.net
"Maciej Sondej" <ma***********@onet.euwrote in message
news:f1**********@news.onet.pl...
Hi,
I have problem. I want to react on event which come from IO.Port(RS232). I
have a class that works on console application
class Program
{
static void Main(string[] args)
{
SerialPortProgram s = new SerialPortProgram();
}
internal static void Run()
{
while(true)
// do nothing
}
}
class SerialPortProgram
{
private SerialPort port = new SerialPort("COM1", 9600, Parity.None, 8,
StopBits.One);
public SerialPortProgram()
{
string text1 = "A";
Console.WriteLine("Incoming Data:");
port.DataReceived += new
SerialDataReceivedEventHandler(port_DataReceived);
port.Open();
WriteToPort(text1);
Program.Run(); // ---- the thread is running so I could recive data from
IO.Port ----
}
[STAThread]
public int WriteToPort(string s)
{
port.Write(s);
return 1;
}
public void ClosePort()
{
port.Close();
}
private void port_DataReceived(object sender, SerialDataReceivedEventArgs
e)
{
Console.WriteLine(port.ReadExisting());
}
}
[STAThread]
public int WriteToPort(string s)
{
port.Write(s);
return 1;
}
public void ClosePort()
{
port.Close();
}
private void port_DataReceived(object sender, SerialDataReceivedEventArgs
e)
{
Console.WriteLine(port.ReadExisting());
}
}
And I don't know how to display recived data from the
port(port.ReadExisting()) for egzample in asp:TextBox.
Can anyone help me?
Thanks for any insight,
Maciek
Of course on the server. I want to react on messages from IO.Port(which is
conneted to server) so I could update some object on the website.
BR
Maciek
Użytkownik "Eliyahu Goldin" <RE**************************@mMvVpPsS.org>
napisał w wiadomości news:ur**************@TK2MSFTNGP02.phx.gbl...
Where is the port you want to read from, on the client or on the server?
--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET] http://msmvps.com/blogs/egoldin http://usableasp.net
"Maciej Sondej" <ma***********@onet.euwrote in message
news:f1**********@news.onet.pl...
>Hi, I have problem. I want to react on event which come from IO.Port(RS232). I have a class that works on console application class Program
{
static void Main(string[] args)
{
SerialPortProgram s = new SerialPortProgram();
}
internal static void Run()
{
while(true)
// do nothing
}
}
class SerialPortProgram
{
private SerialPort port = new SerialPort("COM1", 9600, Parity.None, 8, StopBits.One);
public SerialPortProgram()
{
string text1 = "A";
Console.WriteLine("Incoming Data:");
port.DataReceived += new SerialDataReceivedEventHandler(port_DataReceived) ;
port.Open();
WriteToPort(text1);
Program.Run(); // ---- the thread is running so I could recive data from IO.Port ----
}
[STAThread]
public int WriteToPort(string s)
{
port.Write(s);
return 1;
}
public void ClosePort()
{
port.Close();
}
private void port_DataReceived(object sender, SerialDataReceivedEventArgs e)
{
Console.WriteLine(port.ReadExisting());
}
}
[STAThread]
public int WriteToPort(string s)
{
port.Write(s);
return 1;
}
public void ClosePort()
{
port.Close();
}
private void port_DataReceived(object sender, SerialDataReceivedEventArgs e)
{
Console.WriteLine(port.ReadExisting());
}
}
And I don't know how to display recived data from the port(port.ReadExisting()) for egzample in asp:TextBox.
Can anyone help me?
Thanks for any insight,
Maciek
A web application will run only in response to a client request. When the
application runs, it can read the port in the same way as the console
application. You can make a code library with all port access methods and
call it from your web page code-behind. You will have a textbox on your page
and will assign to it value as
myTextBox.Text = myCodeLibrary.myMethodThatGetsDataFromThePort();
--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET] http://msmvps.com/blogs/egoldin http://usableasp.net
"Maciej Sondej" <ma***********@onet.euwrote in message
news:f1**********@news.onet.pl...
Of course on the server. I want to react on messages from IO.Port(which is
conneted to server) so I could update some object on the website.
BR
Maciek
Użytkownik "Eliyahu Goldin" <RE**************************@mMvVpPsS.org>
napisał w wiadomości news:ur**************@TK2MSFTNGP02.phx.gbl...
>Where is the port you want to read from, on the client or on the server?
-- Eliyahu Goldin, Software Developer & Consultant Microsoft MVP [ASP.NET] http://msmvps.com/blogs/egoldin http://usableasp.net
"Maciej Sondej" <ma***********@onet.euwrote in message news:f1**********@news.onet.pl...
>>Hi, I have problem. I want to react on event which come from IO.Port(RS232). I have a class that works on console application class Program
{
static void Main(string[] args)
{
SerialPortProgram s = new SerialPortProgram();
}
internal static void Run()
{
while(true)
// do nothing
}
}
class SerialPortProgram
{
private SerialPort port = new SerialPort("COM1", 9600, Parity.None, 8, StopBits.One);
public SerialPortProgram()
{
string text1 = "A";
Console.WriteLine("Incoming Data:");
port.DataReceived += new SerialDataReceivedEventHandler(port_DataReceived );
port.Open();
WriteToPort(text1);
Program.Run(); // ---- the thread is running so I could recive data from IO.Port ----
}
[STAThread]
public int WriteToPort(string s)
{
port.Write(s);
return 1;
}
public void ClosePort()
{
port.Close();
}
private void port_DataReceived(object sender, SerialDataReceivedEventArgs e)
{
Console.WriteLine(port.ReadExisting());
}
}
[STAThread]
public int WriteToPort(string s)
{
port.Write(s);
return 1;
}
public void ClosePort()
{
port.Close();
}
private void port_DataReceived(object sender, SerialDataReceivedEventArgs e)
{
Console.WriteLine(port.ReadExisting());
}
}
And I don't know how to display recived data from the port(port.ReadExisting()) for egzample in asp:TextBox.
Can anyone help me?
Thanks for any insight,
Maciek
Hi,
Thank you for your response. It isn't exactly what I wanted, but this
solution is also good.
BR
Maciek
Użytkownik "Eliyahu Goldin" <RE**************************@mMvVpPsS.org>
napisał w wiadomości news:O1**************@TK2MSFTNGP06.phx.gbl...
>A web application will run only in response to a client request. When the application runs, it can read the port in the same way as the console application. You can make a code library with all port access methods and call it from your web page code-behind. You will have a textbox on your page and will assign to it value as
myTextBox.Text = myCodeLibrary.myMethodThatGetsDataFromThePort();
--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET] http://msmvps.com/blogs/egoldin http://usableasp.net
"Maciej Sondej" <ma***********@onet.euwrote in message
news:f1**********@news.onet.pl...
>Of course on the server. I want to react on messages from IO.Port(which is conneted to server) so I could update some object on the website.
BR Maciek
Użytkownik "Eliyahu Goldin" <RE**************************@mMvVpPsS.org> napisał w wiadomości news:ur**************@TK2MSFTNGP02.phx.gbl...
>>Where is the port you want to read from, on the client or on the server?
-- Eliyahu Goldin, Software Developer & Consultant Microsoft MVP [ASP.NET] http://msmvps.com/blogs/egoldin http://usableasp.net
"Maciej Sondej" <ma***********@onet.euwrote in message news:f1**********@news.onet.pl... Hi, I have problem. I want to react on event which come from IO.Port(RS232). I have a class that works on console application class Program
{
static void Main(string[] args)
{
SerialPortProgram s = new SerialPortProgram();
}
internal static void Run()
{
while(true)
// do nothing
}
}
class SerialPortProgram
{
private SerialPort port = new SerialPort("COM1", 9600, Parity.None, 8, StopBits.One);
public SerialPortProgram()
{
string text1 = "A";
Console.WriteLine("Incoming Data:");
port.DataReceived += new SerialDataReceivedEventHandler(port_DataReceive d);
port.Open();
WriteToPort(text1);
Program.Run(); // ---- the thread is running so I could recive data from IO.Port ----
}
[STAThread]
public int WriteToPort(string s)
{
port.Write(s);
return 1;
}
public void ClosePort()
{
port.Close();
}
private void port_DataReceived(object sender, SerialDataReceivedEventArgs e)
{
Console.WriteLine(port.ReadExisting());
}
}
[STAThread]
public int WriteToPort(string s)
{
port.Write(s);
return 1;
}
public void ClosePort()
{
port.Close();
}
private void port_DataReceived(object sender, SerialDataReceivedEventArgs e)
{
Console.WriteLine(port.ReadExisting());
}
}
And I don't know how to display recived data from the port(port.ReadExisting()) for egzample in asp:TextBox.
Can anyone help me?
Thanks for any insight,
Maciek
you need to change your model a little bit. the client can only poll the
server, not recieve events. this means you need a background thread that
monitors the serial port and buffers the input. the web page request can
then look at the buffered data.
you probably want this thread in a service rather an an asp.net thread,
as asp.net applications do not start until a request, and auto shutdown
after a timeout.
-- bruce (sqlwork.com)
Maciej Sondej wrote:
Hi,
I have problem. I want to react on event which come from IO.Port(RS232). I
have a class that works on console application
class Program
{
static void Main(string[] args)
{
SerialPortProgram s = new SerialPortProgram();
}
internal static void Run()
{
while(true)
// do nothing
}
}
class SerialPortProgram
{
private SerialPort port = new SerialPort("COM1", 9600, Parity.None, 8,
StopBits.One);
public SerialPortProgram()
{
string text1 = "A";
Console.WriteLine("Incoming Data:");
port.DataReceived += new SerialDataReceivedEventHandler(port_DataReceived);
port.Open();
WriteToPort(text1);
Program.Run(); // ---- the thread is running so I could recive data from
IO.Port ----
}
[STAThread]
public int WriteToPort(string s)
{
port.Write(s);
return 1;
}
public void ClosePort()
{
port.Close();
}
private void port_DataReceived(object sender, SerialDataReceivedEventArgs e)
{
Console.WriteLine(port.ReadExisting());
}
}
[STAThread]
public int WriteToPort(string s)
{
port.Write(s);
return 1;
}
public void ClosePort()
{
port.Close();
}
private void port_DataReceived(object sender, SerialDataReceivedEventArgs e)
{
Console.WriteLine(port.ReadExisting());
}
}
And I don't know how to display recived data from the
port(port.ReadExisting()) for egzample in asp:TextBox.
Can anyone help me?
Thanks for any insight,
Maciek
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Marco Martin |
last post by:
Hi,
I'm writing an application that reads a serial port and 1)updates a list and
sends data to a graph.
When I run the application, nothing happens unless I put a break point
anywhere in my...
|
by: Efim |
last post by:
Hi,
I have got some problem with sending of events in .NET.
I am using remouting.
The client has got 2 objects for receiving different types of events
(responses and events)
The server has got...
|
by: |
last post by:
I'm trying to create a project on a virtual server that runs on port 8000, rather than port 80.
I tried creating the project at http://localhost:8000/MyFolder but it keeps telling me that the file...
|
by: BigAl.NZ |
last post by:
Hi Guys,
I am trying to write/copy some code that uses events with a GPS.
Everytime the GPS position updates the event fires.
The GPS code is from a SDK Library that I got called GPS Tools...
|
by: guyarkam |
last post by:
I have the following code in which I use events to read on eth or
serial port when data commes in. The ASCHFProtLib library is a third
party library that I have to use as it is. Unfortunately this...
|
by: TS |
last post by:
i just noticed the website i created in VS 2005 is running on a different
port than the default. I see that it is running on the local web server, and
also that the website i created isn't in IIS....
|
by: TC |
last post by:
Hey All,
I have some classes that I recently built for a website which uses the
HttpWebRequest & HttpWebResponse objects from the System.Net namespace.
Basically, the classes rap submitted data...
|
by: ScripterSam |
last post by:
Hi Friends...
Here is my question...
I have an html page with some scripts written on it
The main work is to down load a .cab file from the server to the local users machine who is using my...
|
by: brucedodds |
last post by:
I would like a particular action to fire every time there's a
mouseover event for any button on my (Access 2003) form. Does anyone
know how to do this without writing an OnMouseOver event...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, youll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
| |