|
write instead of your code like this code.
use:
create a delegate like this:
private delegate void Update();
private void port_DataReceived(object sender, SerialDataReceivedEventArgs e)
{
port.DtrEnable = true;
port.Handshake = Handshake.RequestToSend;
this.invoke(new invoker Update(this.refresh));
}
private void refresh()
{
txtData.Text = txtData.Text + port.ReadExisting();
}
|
|
|
|
|
sorry this code was wrong:
write this:
private delegate void Updatedatas();
private void port_DataReceived(object sender, SerialDataReceivedEventArgs e)
{
port.DtrEnable = true;
port.Handshake = Handshake.RequestToSend;
this.invoke(new Updatedatas(this.refresh));
}
private void refresh()
{
txtData.Text = txtData.Text + port.ReadExisting();
}
|
|
|
|
|
Hi, Thanks for your help..
but, still it isn't receiving any thing..
could anyone plz help me to resolve this issue....
-- modified at 7:03 Wednesday 27th June, 2007
|
|
|
|
|
I think you have to set the RtsEnable flag.
port.RtsEnable = true;
try it out
|
|
|
|
|
Hi,
this is my 4-step advise to you:
1.
first make sure you dont get anything in your app: try to read one byte (a raw byte,
not a char, not a string) and show it on the Console (this avoids all GUI trouble,
crossthread problems, etc).
2.
if that fails make sure there is something to receive on the serial cable:
try another program, such as hyperterminal. As long as that does not receive anything,
check your cable, your port settings, your target device; if necessary, use
an oscilloscope or whatever to debug the hardware/firmware.
3.
Once hyperterminal shows something reasonable, return to your app.
Again I recommend reading bytes (a byte array) rather than ReadExisting()
until you start getting data, since I expect that has better chance of delevering
something (it avoids Encoding problems and the like). Check your handshaking;
and try a different one.
4.
When things are getting alive, now start reading chars and/or strings.
Remark: in another thread I got the impression serial port was NOT using ASCII encoding
by default, it seemed to be using Unicode instead.
Good hunting !
|
|
|
|
|
What do you want to pay, for somebody doing your homework?
|
|
|
|
|
i will give him 50% discount
so what is your offer ??
When you get mad...THINK twice that the only advice
Tamimi - Code
|
|
|
|
|
You shouldn't dump the prices here on the forum!
You destroy the marked, and then one day we have to help people for free here!
|
|
|
|
|
Martin# wrote: and then one day we have to help people for free here
man not today , i need some cash
When you get mad...THINK twice that the only advice
Tamimi - Code
|
|
|
|
|
Hi,
Can anyone of u suggest different types of containers present in c#.The containers should have a capability of withholding images,text.... and should be capable of exporting these images when required.
so pls list out all possible containers
-- modified at 2:26 Thursday 28th June, 2007
srujana
|
|
|
|
|
hi,
The richtextbox is not a container control. It renders rtf formatted text into pictures etc.
The controls that derive from ContainerControl are container controls!
Check MSDN or Reflector for containercontrol.
Gideon
|
|
|
|
|
i try to control serialport with C#.i use laptop and USB-RS232 changer.nowadays i see window's blue error screen than my laptop close.why i see this error?how can i block this?how can i correct it?
|
|
|
|
|
hi
i create an application that use crystal report for reports
when i test application in a computer that have .net has no problem, but when i run my application that has not .net (visual studio) show follow exception :
crystaldecisions.crystalreports.engine
how can correct this problem?
tanks
|
|
|
|
|
How to Create a DLL Library using C# ? The DLL be called by the C/COBOL (legacy language )?
|
|
|
|
|
I have posted this before, but now I have some more information. Many thanks to those who tried to help 1st time.
I have a windows form with a rapidly updating chart, and I want to use double buffering to prevent flicker. Without double buffering my app runs OK (apart from the flickering). With double buffering it starts up OK, but when I load the double buffered form the following occurs:-
The form loads then runs the paint method:-
private void Diagnostics_Paint(object sender, PaintEventArgs e)
{
Graphics ChartGraphics = e.Graphics;
ChartGraphics.DrawImage(DiagChart.Image, DiagChart.OutLine.Left, DiagChart.OutLine.Top);
ChartGraphics.Dispose();
if(Started)
StaticBtn.Enabled = false;
}
Then it runs:-
Application.Run(new SC226());
which causes an ArgumentException "Parameter is not valid". SC226 is my application, so shouldn't this line only run when the application is launched? If I comment out the first 3 lines of the paint method it doesn't run the "Application.Run" line and I don't get the exception(but my chart doesn't draw). Can anyone help please?
|
|
|
|
|
Do you catch any exceptions somewhere that shut down your application and then restart it? There's no way a class in the System.Drawing namespace would call Application.Run().
|
|
|
|
|
Eduard Keilholz wrote: Do you catch any exceptions somewhere that shut down your application and then restart it?
No there is nothing in my code that restarts the app.
|
|
|
|
|
Richard W Allen wrote: ChartGraphics.Dispose();
You shouldn't be disposing objects you didn't create by calling 'new' on them
|
|
|
|
|
leppie wrote: You shouldn't be disposing objects you didn't create by calling 'new' on them
right, especially if you add "... unless you obtained them from a method with Create in
its name, as in CreateGraphics".
|
|
|
|
|
leppie wrote: You shouldn't be disposing objects you didn't create by calling 'new' on them
Many many thanks - that did the trick!!
|
|
|
|
|
I'm new to C# and use VS Express 2005 and SQL Express 2005.
Question:
1. I have added Employee.mdf database via Project->Add new item->SQL database
2. Using the following, but see strange things:
SqlConnection sqlcon = new SqlConnection(connectionstring);
- If I use connectionstring as:
"Data Source=.\\SQLEXPRESS;Initial Catalog=Employee;Integrated Security=true; User Instance=True"
I get error like: User domain/user passoword failed! No remote access etc strane errors
- If I use connectionstring as:
"Data Source=.\\SQLEXPRESS;AttachDbFilename=\"C:\\Documents and Settings\\user\\My Documents\\Visual Studio 2005\\Projects\\MyDatabase\\MyDatabase\\Employee.mdf\";Integrated Security=True;User Instance=True"
Then it works fine!
But in every book I see, they give the above 1st case but it does not work for me? Any idea? Is it fine to explicitly using the database path in C# project?
|
|
|
|
|
|
How to setup user in SQL with WIndows login credentials?
|
|
|
|
|
Hi,
Mmm wasnt sure what to put in the subject lol anyways,
Im busy with a web app and one of my pages contain quite a few controls for input.
There are a few conditions of when certain controls need to be visible or not.
Can anyone please give me some advice or suggestions on how to write proper code in working with conditions in this situation instead of hardcoding everything in a messy way.
Please let me know if I didnt explain properly.
Thanks
|
|
|
|
|
This is not the web dev forum, but you can set the Visible property of your control to false and true as you please.
Cheers,
Vıkram.
After all is said and done, much is said and little is done.
|
|
|
|