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)
{
SerialPortProgr am s = new SerialPortProgr am();
}
internal static void Run()
{
while(true)
// do nothing
}
}
class SerialPortProgr am
{
private SerialPort port = new SerialPort("COM 1", 9600, Parity.None, 8,
StopBits.One);
public SerialPortProgr am()
{
string text1 = "A";
Console.WriteLi ne("Incoming Data:");
port.DataReceiv ed += new SerialDataRecei vedEventHandler (port_DataRecei ved);
port.Open();
WriteToPort(tex t1);
Program.Run(); // ---- the thread is running so I could recive data from
IO.Port ----
}
[STAThread]
public int WriteToPort(str ing s)
{
port.Write(s);
return 1;
}
public void ClosePort()
{
port.Close();
}
private void port_DataReceiv ed(object sender, SerialDataRecei vedEventArgs e)
{
Console.WriteLi ne(port.ReadExi sting());
}
}
[STAThread]
public int WriteToPort(str ing s)
{
port.Write(s);
return 1;
}
public void ClosePort()
{
port.Close();
}
private void port_DataReceiv ed(object sender, SerialDataRecei vedEventArgs e)
{
Console.WriteLi ne(port.ReadExi sting());
}
}
And I don't know how to display recived data from the
port(port.ReadE xisting()) for egzample in asp:TextBox.
Can anyone help me?
Thanks for any insight,
Maciek 5 1826
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)
{
SerialPortProgr am s = new SerialPortProgr am();
}
internal static void Run()
{
while(true)
// do nothing
}
}
class SerialPortProgr am
{
private SerialPort port = new SerialPort("COM 1", 9600, Parity.None, 8,
StopBits.One);
public SerialPortProgr am()
{
string text1 = "A";
Console.WriteLi ne("Incoming Data:");
port.DataReceiv ed += new
SerialDataRecei vedEventHandler (port_DataRecei ved);
port.Open();
WriteToPort(tex t1);
Program.Run(); // ---- the thread is running so I could recive data from
IO.Port ----
}
[STAThread]
public int WriteToPort(str ing s)
{
port.Write(s);
return 1;
}
public void ClosePort()
{
port.Close();
}
private void port_DataReceiv ed(object sender, SerialDataRecei vedEventArgs
e)
{
Console.WriteLi ne(port.ReadExi sting());
}
}
[STAThread]
public int WriteToPort(str ing s)
{
port.Write(s);
return 1;
}
public void ClosePort()
{
port.Close();
}
private void port_DataReceiv ed(object sender, SerialDataRecei vedEventArgs
e)
{
Console.WriteLi ne(port.ReadExi sting());
}
}
And I don't know how to display recived data from the
port(port.ReadE xisting()) 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******** ******@TK2MSFTN GP02.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)
{
SerialPortProgr am s = new SerialPortProgr am();
}
internal static void Run()
{
while(true)
// do nothing
}
}
class SerialPortProgr am
{
private SerialPort port = new SerialPort("COM 1", 9600, Parity.None, 8, StopBits.One );
public SerialPortProgr am()
{
string text1 = "A";
Console.WriteL ine("Incoming Data:");
port.DataRecei ved += new SerialDataRece ivedEventHandle r(port_DataRece ived);
port.Open();
WriteToPort(te xt1);
Program.Run( ); // ---- the thread is running so I could recive data from IO.Port ----
}
[STAThread]
public int WriteToPort(str ing s)
{
port.Write(s );
return 1;
}
public void ClosePort()
{
port.Close() ;
}
private void port_DataReceiv ed(object sender, SerialDataRecei vedEventArgs e)
{
Console.WriteL ine(port.ReadEx isting());
}
}
[STAThread]
public int WriteToPort(str ing s)
{
port.Write(s );
return 1;
}
public void ClosePort()
{
port.Close() ;
}
private void port_DataReceiv ed(object sender, SerialDataRecei vedEventArgs e)
{
Console.WriteL ine(port.ReadEx isting());
}
}
And I don't know how to display recived data from the port(port.Read Existing()) 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.m yMethodThatGets DataFromThePort ();
--
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******** ******@TK2MSFTN GP02.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.p l...
>>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)
{
SerialPortProgr am s = new SerialPortProgr am();
}
internal static void Run()
{
while(true)
// do nothing
}
}
class SerialPortProgr am
{
private SerialPort port = new SerialPort("COM 1", 9600, Parity.None, 8, StopBits.One) ;
public SerialPortProgr am()
{
string text1 = "A";
Console.Write Line("Incoming Data:");
port.DataRece ived += new SerialDataRec eivedEventHandl er(port_DataRec eived);
port.Open() ;
WriteToPort(t ext1);
Program.Run() ; // ---- the thread is running so I could recive data from IO.Port ----
}
[STAThread]
public int WriteToPort(str ing s)
{
port.Write(s) ;
return 1;
}
public void ClosePort()
{
port.Close( );
}
private void port_DataReceiv ed(object sender, SerialDataRec eivedEventArgs e)
{
Console.Write Line(port.ReadE xisting());
}
}
[STAThread]
public int WriteToPort(str ing s)
{
port.Write(s) ;
return 1;
}
public void ClosePort()
{
port.Close( );
}
private void port_DataReceiv ed(object sender, SerialDataRec eivedEventArgs e)
{
Console.Write Line(port.ReadE xisting());
}
}
And I don't know how to display recived data from the port(port.Rea dExisting()) 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******** ******@TK2MSFTN GP06.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.m yMethodThatGets DataFromThePort ();
--
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******** ******@TK2MSFTN GP02.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(RS23 2). I have a class that works on console application class Program
{
static void Main(string[] args)
{
SerialPortProgr am s = new SerialPortProgr am();
}
internal static void Run()
{
while(true)
// do nothing
}
}
class SerialPortProgr am
{
private SerialPort port = new SerialPort("COM 1", 9600, Parity.None, 8, StopBits.One );
public SerialPortProgr am()
{
string text1 = "A";
Console.Writ eLine("Incoming Data:");
port.DataRec eived += new SerialDataRe ceivedEventHand ler(port_DataRe ceived);
port.Open( );
WriteToPort( text1);
Program.Run( ); // ---- the thread is running so I could recive data from IO.Port ----
}
[STAThread]
public int WriteToPort(str ing s)
{
port.Write(s );
return 1;
}
public void ClosePort()
{
port.Close() ;
}
private void port_DataReceiv ed(object sender, SerialDataRe ceivedEventArgs e)
{
Console.Writ eLine(port.Read Existing());
}
}
[STAThread]
public int WriteToPort(str ing s)
{
port.Write(s );
return 1;
}
public void ClosePort()
{
port.Close() ;
}
private void port_DataReceiv ed(object sender, SerialDataRe ceivedEventArgs e)
{
Console.Writ eLine(port.Read Existing());
}
}
And I don't know how to display recived data from the port(port.Re adExisting()) 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)
{
SerialPortProgr am s = new SerialPortProgr am();
}
internal static void Run()
{
while(true)
// do nothing
}
}
class SerialPortProgr am
{
private SerialPort port = new SerialPort("COM 1", 9600, Parity.None, 8,
StopBits.One);
public SerialPortProgr am()
{
string text1 = "A";
Console.WriteLi ne("Incoming Data:");
port.DataReceiv ed += new SerialDataRecei vedEventHandler (port_DataRecei ved);
port.Open();
WriteToPort(tex t1);
Program.Run(); // ---- the thread is running so I could recive data from
IO.Port ----
}
[STAThread]
public int WriteToPort(str ing s)
{
port.Write(s);
return 1;
}
public void ClosePort()
{
port.Close();
}
private void port_DataReceiv ed(object sender, SerialDataRecei vedEventArgs e)
{
Console.WriteLi ne(port.ReadExi sting());
}
}
[STAThread]
public int WriteToPort(str ing s)
{
port.Write(s);
return 1;
}
public void ClosePort()
{
port.Close();
}
private void port_DataReceiv ed(object sender, SerialDataRecei vedEventArgs e)
{
Console.WriteLi ne(port.ReadExi sting());
}
}
And I don't know how to display recived data from the
port(port.ReadE xisting()) 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 code. then I can see the data and everything gets updated,
until the next time I put a break in the code. Otherwise, I have to put a
break on the thread(200ms) and everything works fine for about 1 minute but
then the program start to lag...
|
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 two objects for sending of these events.
The client opens tcp port 0 to receive events:
if (ChannelServices.GetChannel("tcp") == null)
{
|
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 path doesn't map to the url. Is there some trick to using different port numbers?
Thanks.
Jerry
|
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 from
www.franson.com
For some reason my code below doesnt work - the GpsFixEvent never seems
to "fire" as it were.
|
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 version
of my code does not work. It seems that the events are not triggering
when there is a data on any of the eth or serial ports. Basicaly all
the events handler functions (OnMsgRecv and similar) are not executed.
I have included a piece of...
| |
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.
My crystal report looks weird because it is trying to show images from the
crystalreportviewers10 virtual directory based on the current website
running, which in this case is localhost:1169, but actuall the
crystalreportviewers10 virtual...
|
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 up, connect to external websites
on external servers and post / remove the data from these other sites.
It works fine locally but when uploaded to the BCentral production server,
the outgoing requests get shutdown.
|
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 wcript..
This .cab contains the dll files and other necessary funtion for my page to work.
Now the problem is that depending on the event returned by the funtions my wcript should take some decisions...
But the script is reacting randomly...
The...
|
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 procedure for
every button?
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |