|
hi
i have an app running with serial comm.
i read my comport for data that i send via an antenna, but to read it serial takes to long
so i was thinking to use wireless ethernet.
but i have no clue how this works
is it simelar to serialport?
and were can i find samples for this?
ive been looking on the net but i didnt find what i was looking for.
any ideas
thx
|
|
|
|
|
faladrim wrote: is it simelar to serialport?
It can be and then again it might not.
Can you provide some more details as to the application?
Regarding the C# side of things both SerialPort & TcpClient or whatever you use to access the TCP/IP side of things will derive from System.IO.Stream so there shouldn't be too much to change on that side of things.
But then again it depends completely on what the application is trying to do.
I have no idea what I just said. But my intentions were sincere.
|
|
|
|
|
well
with a microprocessor i send data to my pc
first i used a serial wire, but later i used two antennas to establish the communication
i made some sort of protocol to send my data u know with a header and an end...
so if i read the data in my pc it takes over 10 min to read all the data im sending
and that is not so mutch.
i have no idea to fasten this up so i thought i maybe could use ethernet because this transfers data mutch faster than serial
but i have no idea how i can read this in my app
now this is port.readchart()
but i have no idea to start comm with ethernet.
thx for the help
|
|
|
|
|
First I would try using some form of simple compression algorithm to see if you can shrink the data first if this is viable. It'll be simpler than changing the hardware.
A second alternative would be to try and find a USB module for the microprocessor, there are drivers available for Windows which make the USB port then look like a very high speed serial port. Nothing would need to be changed in the code except for the baud rate to reflect the change in speed.
Thirdly, to read data over an ethernet connection you need to establish a connection using the System.Net.(Sockets?.)TcpClient class. Basically you connect to a specific IP address and port number and the TcpClinet is inherited from System.IO.Stream so you can create a StreamReader / Writer, BinaryReader / Writer etc from this to read in the data however you want.
E.g. (this is off the top of my head so I can't verify it's accuracy)
TcpClient micro = new TcpClient(ipAdressOfMicro, portNumber);
StreamReader microInput = new StreamReader(micro.BaseStream);
string line = microInput.ReadLine();
I have no idea what I just said. But my intentions were sincere.
|
|
|
|
|
I am trying to invoke and kill and instance of another application (IE Explorer in my case) from my program. System.Diagnostics.Process would have worked beautifully if I was not targeting the CF 1.0 (Aaaarrrgghhh!!!! )
So now I've resorted to using CreateProcess in coredll.dll which is a little bit more hairy but does the trick. Code looks like this:
[DllImport("coredll.dll", SetLastError=true)]<br />
static extern bool CreateProcess(String imageName, String cmdLine, IntPtr lpProcessAttributes, IntPtr lpThreadAttributes, bool boolInheritHandles, Int32 dwCreationFlags, IntPtr lpEnvironment, IntPtr lpszCurrentDir, byte[] si, ProcessInfo pi);<br />
.<br />
.<br />
.<br />
ProcessInfo pi = new ProcessInfo();<br />
byte[] si = new byte[128];<br />
bool result = CreateProcess ("iexplorer.exe", "http://www.codeproject.com", IntPtr.Zero, IntPtr.Zero, false, 0, IntPtr.Zero, IntPtr.Zero, si, pi);
ProcessInfo is a class defined as follows:
public class ProcessInfo<br />
{<br />
public IntPtr hProcess;<br />
public IntPtr hThread;<br />
public Int32 ProcessId;<br />
public Int32 ThreadId;<br />
}
All of the above works but I am stuck nw at the point where I need to kill this process. I believe TerminateProcess is not the way to go as it does not shut down the process gracefully. It seems I will have to use PostMessage to send a WM_CLOSE message to the process - which is where I'm stuck.
Could anyone help me to get past this hurdle please?
|
|
|
|
|
What is the problem ?
You can post or send messages to any process, it needs PInvoke and a prototype such as
the one below (argument types may vary, depending on what you need exactly).
[DllImport("user32.dll", EntryPoint="SendMessageA", CallingConvention=CallingConvention.StdCall)]
private static extern int SendMessage(int Hdc, uint Msg_Const, int wParam, int lParam);
For WM_CLOSE you would need Msg_Const==0x10, wParam=0, lParam=0.
It only becomes tricky when you want to post/send another message that needs a pointer
to something, since that pointer then must be valid in the target process (there are some
articles on this on CP).
Luc Pattyn
|
|
|
|
|
Well, i don't know what the problem is. I pretty much did what you suggested but I used PostMessage as opposed to SendMessage . I have now tried your method also but its not killing the process.
I am making an assumption which could be the source of my problem - obtaining the handle to the process (the int Hdc parameter that is). I was assuming that I get the handle from the hProcess variable in the ProcessInfo class (the final parameter of the CreateProcess function. Was this assumption wrong perhaps? If so, how do I get the handle to the process that I want to send the message to?
Thanks again.
|
|
|
|
|
Hi,
SendMessage/PostMessage need a handle to a window, not a process.
CreateProcess returns a handle to the process created, so you still must translate
that into a window handle (maybe with GetMainWnd or something like that).
Greetings,
Luc Pattyn
|
|
|
|
|
Hi,
Can any body tell me
1. How can i programmatically get the instance name of SQL express on a system?
2. Sometimes we connect with SQL express using its instance name and on some systms we dont use the instance name, what is the difference between the two?
3.How can i adapt my Connectin String considering this situation? Below is the example
con.ConnectionString=".......Data Source=secb";
con.ConnectionString=".......Data Source=secb\\SQLExpress";
4. How can i enumerate only SQL Express instances on the local system?
Thanks in advance,
Wasif Ehsan.
|
|
|
|
|
There's an SqlEnumerator class or something named similar in one of the System.Data namespaces. I think it's under System.Data.Sql but it may be under the System.Data.SqlClient namespace.
I have no idea what I just said. But my intentions were sincere.
|
|
|
|
|
|
Hi All,
How can I select more than one subitem
of multiple items in a listview?
I need to do this when I click the subitems
by pressing CTRL, not by code.
Any suggestions would be greatly appreciated.
Thanks in advance,
Sarvan AL
|
|
|
|
|
Not possible in the standard Windows.Forms control AFAIK, try using the DataGridView or another ListView control. There are a couple available on CP.
I have no idea what I just said. But my intentions were sincere.
|
|
|
|
|
hi friends
can anyone plz guide me on the exception
An unhandled exception of type 'System.IndexOutOfRangeException' occurred in system.windows.forms.dll<br />
<br />
Additional information: Index was outside the bounds of the array.<br />
heres the code that gives me the exception
int count=4;<br />
int[] indice = new int[count]; <br />
MessageBox.Show(count.ToString());<br />
for(int i=0;i<count;i++)<br />
indice[i] = TableListBox.CheckedIndices[i];<--Exception<br />
return indice;
plz reply quickly
|
|
|
|
|
can you tell me what is this?
for(int i=0;i indice[i] = TableListBox.CheckedIndices[i];<--Exception
|
|
|
|
|
sorry about that i copied the incorrect code. the for loop looks like this
int count=4;<br />
int[] indice = new int[count]; <br />
for(int i=0;i<count;i++)<br />
{<br />
indice[i] = TableListBox.CheckedIndices[i]; <br />
}<br />
return indice;
TableList Box is a CheckedListBox.
what this loop does is takes the item on the selected index of the list box and stores it in another array.
|
|
|
|
|
check the size of TableListBox.it should not be greater than count
|
|
|
|
|
the size property of the listbox just gives its width and height.
what has that got to do with the exception??
|
|
|
|
|
i am not talking about the physical size.
i am talking about the count.
check during run time.just place a brek point in the for loop and see whether TableList[i] is not greater than TableList[count].
right??
|
|
|
|
|
I believe that your error is that there is less than 4 checked items in the Table listBox so when the compiler tries to go to (for example) index 4 it is not found and it is out of range.
try knowing how many items are checked before you initialize the other array and u do the for loop.
you can do this
<br />
int count = TableListBox.CheckedIndices.Count;<br />
and continue the rest of your code
|
|
|
|
|
i've already checked that the number of items selected in the listbox are 4 through
int count=TableListBox.CheckedIndices.Count;
approach.
but still it doesn't work. Any other suggestions???
|
|
|
|
|
Sorry,
i cann't see any error in the code you are providing.
Try providing us more information and maybe we can help
|
|
|
|
|
can this be due to the .Net Platform being corrupt?
i'm really confused
|
|
|
|
|
Is it the first time you develop on this Platform?
|
|
|
|
|
The odds of that are close to zero.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|