|
"There are a lot of issues with serially receiving data, especially when data rates are high..." has got to be the understatement of the year!
I worked for 7 years at a hardware store running 50 serial terminals on one IBM desktop PC. Some of the runs were 300' long, via surplus telephone cable that the owner found and installed before I went to work there. It was my unpleasant job to maintain the system and keep it working, despite the fact that it broke every RS232 standard ever published. What a nightmare!
Will Rogers never met me.
|
|
|
|
|
Roger Wright wrote: "There are a lot of issues ..." has got to be the understatement of the year!
I can't see an understatement here.
Now if I had said: "occasionally a thing or two could go wrong..." that would be an understatement.
Roger Wright wrote: Some of the runs were 300' long
Anything can fail when you use it outside the specified conditions. RS232C is spec'd at a maximum of 15m IIRC. Any failure under unsupported conditions should not reflect on the vendors of the subsystems used (PC, Windows, ...).
|
|
|
|
|
It's (in the one revision I'm most used to) 50' at 9600 bps. We used 300' at 19.2 kbps. But I kept the damned thing working for years, while secretly undermining the boss and installing Cat5 in my spare time.
Will Rogers never met me.
|
|
|
|
|
Undermine with cable, I like that.
|
|
|
|
|
Thats good no bug in Serial Port class, I think the problem is down too small a buffer in the Controller, like I thought. Now all I have to ask is how bad is my hack to get around it, my thinking was a bit inefficient but.....
modified 4-Nov-11 5:12am.
|
|
|
|
|
If the board was my design, I would have started slow. Colleague designed it and the phrase used was "well that is done it works with HyperTerm". Told to "learn how to do comms properly", I don't think that helps at all. My knowledge of Serial Port Class comes from Jan Axelsons book & MSDN I used MSComm & MHComm before that!
modified 4-Nov-11 7:01am.
|
|
|
|
|
Hi,
I'm trying to write a function in a c++/cli dll that will receive an empty array from C# (float[] a), use gcnew to allocate the array and then I need to use the array in C#. I tried regular transfer but after the function returns the array is still null in C#. Current trial is:
C#:
float[] a;
InitArray(a);
c++/cli:
void CLIClass::InitArray(array<float>^ a)
{
a = gcnew array<float>(100);
for(int i=0; i<100; i++)
a[i] = 10.0F;
}
I do not wish to return the array as a return value (the function should actually return 3 arrays).
Thanks!
|
|
|
|
|
Does passing a tracking reference work?
void CLIClass::InitArray(array<float>^% a)
Mark Salsbery
|
|
|
|
|
Yes, all I was missing is the % operator. Thanks!
|
|
|
|
|
I gave him a 5. It's nice when you do that when people help you out here.
|
|
|
|
|
|
your C# code should use the out or ref keyword:
float[] a;
InitArray(out a);
float[] a=null;
InitArray(ref a);
ref would fail here as long as a isn't initialized.
Without ref/out your callee can modify the array content, however it can't replace the array.
|
|
|
|
|
******************************************************
the code works as follows.
If you chose them all, works fine, but not all, of one or more than one election, or choose not at all, the program does not work
stands in this code.
if (dr.Cells [0]. Value.ToString ()! = "true")
How do we solve the problem?
List<int> TestId = new List<int>();
for (int i = 0; i < dataGridView2.RowCount; i++)
{
foreach (DataGridViewRow dr in dataGridView2.Rows)
{
if (dr.Cells[0].Value.ToString() != "true")
{
TestId.Add(Convert.ToInt32(dr.Cells[2].Value.ToString()));
}
}
}
if (baglanti.State == ConnectionState.Closed)
baglanti.Open();
komut.Connection = baglanti;
for (int i = 0; i < TestId.Count; i++)
{
komut.CommandText = "update HASTA_SONUCLARI SET ONAYLANDI='" + true + "' where PROTOKOL_NO='" + TextBox6.Text + "' and TEST_NO='" + TestId + "'";
komut.ExecuteNonQuery();
}
MessageBox.Show("Onaylandı.");
baglanti.Close();
}
}
|
|
|
|
|
what a horrible message. The code isn't formatted properly, there are plenty of unjustified ToString() calls and string comparisons, and "doesn't work" doesn't even start to explain what the problem is.
Please read the forum guidelines ("How to get an answer to your question" at the top of this forum), and see how others post their message. Good questions yield good answers here.
|
|
|
|
|
Actually I wanted to report this message to the Hall of Shame.
Look:
- You run in nested loops several times through your DataGridView
for (int i = 0; i < dataGridView2.RowCount; i++) {
foreach (DataGridViewRow dr in dataGridView2.Rows)
- You compare boolean values as a strings - it will fail with localized versions!
if (dr.Cells[0].Value.ToString() != "true")
By the way, I posted such a coding horror some time ago. It was very hard to find out why the program strangely failed on that one computer.
- You create SQL queries by adding strings together. TextBox6 might contain bad code (SQL injection attack). Use parameterized queries instead.
- You add an array of numbers where one number is required:
and TEST_NO='" + TestId + "'";
instead of
and TEST_NO='" + TestId[i] + "'";
And that looks like using strings instead of numbers...
|
|
|
|
|
Hi,
i want do send an email, with a 'link' including parameters to a pc user. If the user clicks on this link a specific webforms c# application should be started, if it is not running, and than an action should be executed.
Example MailText:
New image received: 'myapplication<imageid=2000>'
Clicking on 'myapplication<imageid=2000>' should (start the application if it is not running and) load my image with id 2000 from db and show it in my application for example.
Is there a easy way to get it work?
The application is not installed locally, it is only available as webforms application.
I did not know how i must define and setup the link in the email in that way, that the user click on the link (with parameters) in the mail is delegated to and handled by my application.
Did someone maybe know a manual or demo project for this case?
Greetings Frank
|
|
|
|
|
Using the Process class[^], you can start a new application in a program of your choice.
Here[^] is a neat sample of how this class has been used to start Notepad.
|
|
|
|
|
It sounds like you want a url link to your web app with a parameter. This can be done simply by including the URL string in the body of the mail. Surely that can't be the issue.
On the other hand if you are wanting to install your application on the recipients hard disk you are talking about the same delivery method as malware, not a good idea.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Hello
I am trying to add a service reference to my solution but it propmpts me errors I use the Ip address with web browsers and it works but when i add the service to my solution it gives me this error
the IP address is MYIP:88/sapco/sapcoservice.asmx?wsdl'
Metadata contains a reference that cannot be resolved: 'http://MYIP:88/sapco/sapcoservice.asmx?wsdl'.
There was an error downloading 'http://MYIP:88/sapco/sapcoservice.asmx?wsdl'.
The request failed with HTTP status 404: Not Found.
Metadata contains a reference that cannot be resolved: 'http://MYIP:88/sapco/sapcoservice.asmx'.
Metadata contains a reference that cannot be resolved: 'http://MYIP/sapco/sapcoservice.asmx'.
|
|
|
|
|
You have already posted this in the WCF and Visual Basic forums; please selct one forum only for your questions.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
Can anyone tell me why I cannot get this code to write to my serial port (microchip) ?
If I send "pin1=2" via the simpleserial object, it is received and the microchip code reacts. When I try and send it through the below method, the data is not received by the microchip and it does not react.
Thanks for reading.
using System;
using System.Collections.Generic;
using System.Text;
using System.IO.Ports;
using System.Windows.Forms;
namespace SimpleSerial
{
class test
{
private void serialPortWrite()
{
SerialPort serialPort1 = new SerialPort();
string lineToWrite = "pin1=2";
serialPort1.PortName = "COM8";
serialPort1.BaudRate = 115200;
serialPort1.DataBits = 8;
serialPort1.Parity = Parity.None;
serialPort1.StopBits = StopBits.One;
serialPort1.Open();
MessageBox.Show(lineToWrite);
foreach (char chr in lineToWrite)
{
char[] buff = new char[1];
buff[0] = chr;
serialPort1.Write(buff, 0, 1);
}
serialPort1.Close();
}
}
}
|
|
|
|
|
Looks like it must be in the options you're using; the write code is the same. (Though I don't understand why you send one byte at a time.)
|
|
|
|
|
Hi Bob,
Thanks for the reply. As you can see, I tried the "writeline" method as well.
In the simpleserial code example, they wrote one byte at a time as a keypress event and so I was trying to mimic that when troubleshooting after "writeline" didn't work.
What do you mean by "options"?
private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
{
if (!serialPort1.IsOpen) return;
char[] buff = new char[1];
buff[0] = e.KeyChar;
serialPort1.Write(buff, 0, 1);
e.Handled = true;
}
|
|
|
|
|
In .NET strings and char contain 16-bit Unicode characters. So your serialPort1.Write(buff, 0, 1) is writing one character, i.e. two bytes; for ASCII characters that effectively means there is a NULL character preceeding every character you really want.
And yes, the MSDN documentation states that ASCII encoding is the default for SerialPort, but something isn't quite right about that. Either set the Encoding property explicitly, or (what I normally do) construct a byte array yourself and send that using the other Write overload.
|
|
|
|
|
Hi Luc!
Thanks for the reply. I set the encoding explicitly and it is not working yet. Can you expand on what you mean by saying that each character that is written is 2 bytes? This is confusing since it should only take 1 byte for each character.
As for the construction of a byte array, should that be something like (even though the compiler doesn't like the equals sign in this case below)
byte[] bytArr = new byte[] { p, i, n, 2, =, 2 };
And then say serialPort1.WriteLine(bytArr)?
or
foreach (byte byt in bytArr)
{
serialPort1.WriteLine(byt)
}
Is that what you are meaning?
|
|
|
|