Hi friends,
I have written code in asp.net to read or write string in com port(COM1).But when i run the program i am not getting any output .Below is my code .How can i check the string which i have send in com port is available in com port for read.
private SerialPort port = new SerialPort("COM 1", 9600, Parity.None, 8, StopBits.One);
port.Open();
// port.Write("He" );
port.Close();
port.Open();
port.ReadTo("e" );
Console.WriteLi ne(port.ReadLin e());
please reply as soon as possible....... ............... ...Thanx in advance for reply...
14 3078
Is it possible to have a serialdatarecei ved args, with the handles in asp.net? If so, try that, maybe its not receiving it yet. You can always look up examples on google.
ex of the data received handler: - Private Sub port_DataReceived(ByVal sender As Object, ByVal e As _
-
System.IO.Ports.SerialDataReceivedEventArgs) Handles port.DataReceived
-
-
End If
-
End Sub
joedeene
Plater 7,872
Recognized Expert Expert
How do you know it is not working?
You know that code will be run on the server's COM port and not on the computer viewing the webpage right?
because after port.write statement i have written
Console.WriteLi ne(port.ReadExi sting()); and in my console window m nog getting any out put;
2)even if i used
port.DataReceiv ed += new SerialDataRecei vedEventHandler (port_DataRecei ved);
private void port_DataReceiv ed(object sender, SerialDataRecei vedEventArgs e)
{
// Show all the incoming data in the port's buffer
Console.WriteLi ne(port.ReadExi sting());
}
this handle does not fire;
Thanx for reply .if you can provide more solution i am waiting to ur suggestion.
Plater 7,872
Recognized Expert Expert
In your example code you call a Close() and then an Open(), why? The data could come in durring that time and you would never see it?
Are you making sure there is no flowcontrol enabled for the port (or enabled if you need to use it)
Because first open port and i am writing the string to send to port like
port.write("str ing")
after writing string i am closing port as suggested somewhere in google.
then i am opening the port and reading the data.
actually i followed this link here is code for that: http://msmvps.com/blogs/coad/archive.../23/39466.aspx Plater 7,872
Recognized Expert Expert
Well that is a bad practice, and nowhere in the article's sample code did I see where it said to close and then open.
You should close the object when you are done with it, if it is not open, how do you expect to receive data?
Can u give me any solution???whic h is good
Plater 7,872
Recognized Expert Expert
Well for testing purposes, try this: -
private SerialPort port = new SerialPort("COM1", 9600, Parity.None, 8, StopBits.One);
-
-
port.Open();
-
port.Write("He");
-
string firstread=port.ReadTo("e");
-
System.Threading.Thread.Sleep(100);//pause for 1/10 a second
-
Console.WriteLine(port.ReadLine());
-
port.Close();
-
Hi,
I did same as u send but still in console window i am not able to see any thing.
is there any other thing,that i need to set in computer
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: collinm |
last post by:
hi
we use linux and c language
under bash i do
echo -e \\000\\000\\000\\000\000\\001Z00\\002AA LINUX \\004 >/dev/ttyS2
that send command to a led display (alpha sign communication)
|
by: collinm |
last post by:
hi
i send a command to a led display, the led display is suppose to return
me some character
i write a string on a serial port
void ledDisplayExist()
{
char msg={'\0', '\0', '\0', '\0', '\0', '\1', 'Z', '0', '0',
|
by: Dakkar |
last post by:
I write a program for connecting to mysql database and read the values
that i want from the database so i wrote my code like this
RegistryKey uo =
Registry.LocalMachine.OpenSubKey("SOFTWARE\\Origin Worlds
Online\\Ultima Online\\1.0");
String folder =
uo.GetValue("ExePath").ToString();
|
by: vkrasner |
last post by:
It works with VS2003 and does not in VS2005:
in VS2003 :
string sMyvalue = ConfigurationSettings.AppSettings;
in VS2005 (does not work!!)
string sMyvalue = ConfigurationManager.AppSettings;
Anybody able to give me idea how-to read by C# element which I add to the
machine.config into the new single section?
|
by: Jens |
last post by:
Hello,
I have been looking for some C-code which listens on a user-defined port
for incoming data traffic. When data is received, the data is written to a
file.
I found some C-code (server) that almost does the job. It listens on a
user-defined
port and responds to incoming data by writing how many times somebody
has tried to connect to the server.
| |
by: daikeechi |
last post by:
hello guys ..
i want to perform pc to pc chatting via null modem cable.. i managed to write and sent data to serial port but how to write loops to read data from serial port ? i'm using visual c++ 2005 express editon .. below is my code ..
#pragma endregion
public: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
String^ msg;
|
by: rowan |
last post by:
I'm writing a driver in Python for an old fashioned piece of serial
equipment. Currently I'm using the USPP serial module. From what I can
see all the serial modules seem to set the timeout when you open a
serial port. This is not what I want to do. I need to change the
timeout each time I do a "read" on the serial port, depending on
which part of the protocol I've got to. Sometimes a return character
is expected within half a second,...
|
by: darkking |
last post by:
Ok,
I'm trying to read data from the serial port. Problem is, that i always have to query the port for new data, and in 99.9% of acses my query doesn't return the result cause of the fact it's done when the modems is seding the answers.
I've tried using a timer, but still i get errors. Same while using DTR enable/false. How i can safely send the query without getting over the momdem response ?
I'm using DataRecived event, to read the...
|
by: madsornomads |
last post by:
Hi all,
I have a problem with reading from a Java server after I have written
to it - it just hangs. It works fine if I just write to the server and
not try to write. I have read the HOWTO on sockets - and it states
that there is a problem (something about flushing), but not what the
solutions is. Nor do google. Can somebody please help?
A few lines down you can see the example code that sums up the
problem. Just change the name of...
|
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: 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: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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: 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: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |