|
Hi Everyone,
I have a windows Application developed with .Net 2005 and C#. It communicates with a device using virtual COM Port. I use Windows XP Home and Prof. It works fine everywhere.
But recently I shipped the software to one of my client. There it creates problem. During its first run the software checks all COM Ports by sending specific command and where it finds proper response it detects that the device is attached to that Port. This is a regular process of the software. But, while checking the COM ports the application gets stuck after sending command to COM Port. And only way to close it is from Task Manager. This happens with 4 to 5 system, the client had tried.
I have also written Log files, there also after sending Command to com port, nothing is logged.
Note : No Anti Virus is installed there; Drivers are installed properly; Device is detected by the system when attached; displayed in device manager
Any suggestion or hint will be greatly appreciated...
Regards,
-SIFAR.
|
|
|
|
|
Sifar - 0 wrote: the software checks all COM Ports by sending ...
That seems to be a bad idea: COM ports can be busy, allocated, non-existing, or connected to special hardware (modem, infra-red, bluetooth,...).
Try the same "sending some command" using HyperTerminal to see it fail.
|
|
|
|
|
Is this a USB device using a virtual COM port? If so, here's what I do to find the COM port it's connected to.
NOTE: I'm not sure what the standard practice is for this, there may be a better way, but this was worked just fine for me so far. If anyone knows of a better, more robust way to do this, I'm open to suggestions.
You can determine which COM port the device is connect to by searching the registry under
HKLM\SYSTEM\CurrentControlSet\Enum\USB\VID_xxxx&PID_xxxx
where xxxx is the hex identifier for the VendorID and ProductID of the device. Inside this key is another subkey for each instance of the device, and then in the Device Parameters key you'll see PortName (I think, can't remember off hand exactly what it is). Anyway, the name of the COM port can be found here. You can iterate through each instance in the registry and attempt to open the .NET SerialPort object. If you successfully open the port, then the device is connected.
So you'll want to look for the key
HKLM\SYSTEM\CurrentControlSet\Enum\USB\VID_xxxx&PID_xxxx\<all subkeys="">\Device Parameters</all>
and read the PortName value from each instance.
foreach(string curPortName in portNames)
{
port.Name = curPortName;
try
{
port.Open();
break;
}
catch(InvalidOperationException ex)
{
}
catch(UnauthorizedAccessException ex){
}
}
You can check the MSDN documentation for how to read info from the Registry in C#.
Dybs
|
|
|
|
|
Thanx Dybs,
I had already tried this approach but it does not work under Windows Vista.
Actually, in Vista when you login as Administrator everything works fine. But with users other than Administrator it does not works. Vista creates different registry entries for othe Users.
I have found below solution :
I have used ManagementObjectCollection and ManagementObjectSearcher.
ManagementObjectCollection ManObjCollection;
ManagementObjectSearcher ManObjSearch;
ManObjSearch = new ManagementObjectSearcher("Select * from Win32_PnPEntity");
ManObjCollection = ManObjSearch.Get();
foreach (ManagementObject ManObj in ManObjCollection)
{
if (ManObj["Name"] == "Name You Are Looking For")
{
}
}
This has worked fine for me with XP and Vista, (Administrator and Non-Administrator) and it is fast also.
Hope this would help you further...
Regards,
-SIFAR.
|
|
|
|
|
Dear All,
How can I show the Windows Mobile circular waiting cursor from my form?
I'm sure it is very easy, but I've been looking for the solution form some time now without aany success.
Thanks in advance,
miguelji
|
|
|
|
|
I would try Cursor=Cursors.WaitCursor;
|
|
|
|
|
Tat was my first try, but in a Windows Mobile 6 device it doesn't work.
I'm probably doing something wrong, but it is so simple that I dont know what can be wrong.
miguelji
|
|
|
|
|
Yes, I think the cursor.waitcursor method may work in your scenario. Windows Mobile by default should display the waiting cursor for you. Is there something specific you are doing inside of your custom app? You didn't leave a lot of details.
|
|
|
|
|
Yes you are right, I was not leaving any detail.
I need to show the waiting cursor while my program performs a series of time consuming tasks. I've isolated the problem and created a WM6 (CF 3.5) application with a single form and a single button in it. Then I write the following code for the click event of the button (I use VB, but this would be the C# equivalent):
----------------------------------------------
Cursor c = default(Cursor);
c = Cursors.WaitCursor;
this.Refresh();
int I = 0;
int J = 0;
for (I = 1; I <= 10000000; I++) {
J = I * 3;
}
c = Cursors.Default;
this.Refresh();
----------------------------------------------
I run the programa, click the button and nothing happens, no cursor is displayed.
What Am I doing wrong here?
Thanks,
miguelji
|
|
|
|
|
Simply try this
Cursor.Current = Cursors.WaitCursor;
Cursor.Show();
and
Cursor.Current = Cursors.Default;
Cursor.Hide();
|
|
|
|
|
Thank you doananhtai!
It works perfect. It was easy, but thank you for being the one to tell how to do it.
Cheers,
miguelji
|
|
|
|
|
Dear All,
I have a critical application for which the performance has to be monitored.
I used the performance monitor in Windows 2003 server to log the data.
I have logged the counters of the Page file bytes and % processor time of the process / the service instance which has to be monitored along with the Processor % Processor time.
When I was analyzing the log I hae found a strange issue, the Processors % Processor time is 88 % but the instances % Processor time is 175 %.
Can any one tell me how this happens and how it is calculated?
Thanks a lot in advance.
Best Regards,
M. J. Jaya Chitra
|
|
|
|
|
Do you have a dual core system? If so the second number appears to be the percentage of time consumed relative to the capacity of a single core.
Today's lesson is brought to you by the word "niggardly". Remember kids, don't attribute to racism what can be explained by Scandinavian language roots.
-- Robert Royall
|
|
|
|
|
M. J. Jaya Chitra wrote: When I was analyzing the log I hae found a strange issue, the Processors % Processor time is 88 % but the instances % Processor time is 175 %
88 percent of 200 == 176
Sounds like you have two processers and the process being performance monitored is multi-threaded.
Best Wishes,
-David Delaune
|
|
|
|
|
Dear Friends,
Yes, I am having the dual core processor.
Both of your post helped me a lot.
Thank you a lot for the timely reply and help.
Best Regards,
M. J. Jaya Chitra
|
|
|
|
|
Hi,
When using DeviceIoControl with METHOD_BUFFERED, will the buffer that windows allocate in kernel (the one that is the copy of user space), would it be taken from the non paged pool ?
I was looking for more specific documentation on the subject and did not find something explicit.
Thanks,
Shay
|
|
|
|
|
Hi Shay,
Yes, METHOD_BUFFERED will allocate the buffer from non-paged pool in the kernel address space. You can take a look at the diagram in the article Using Buffered I/O[^] to see an overview of the buffered I/O transfer method.
Best Wishes,
-David Delaune
|
|
|
|
|
Thanks Dave, I ended up finding this link as well.
Shay
|
|
|
|
|
Hi everybody,
I am planning a PIN PAD and to get response from the device needs to send the command CE, does anyone know how can I do?
Thanks
|
|
|
|
|
|
Thanks for responding.
Try to explain better, I have a PIN PAD to achieve communication with the device, I will send a command more or less well <stx> CE0 <ext> <lrc>, the calculation of the LRC is on each byte without taking into account the first , ie C XOR E XOR 0 XOR EXT and sends me a number, however when sending information to the CE device I have to send as a command, not byte by byte like I'm doing now, but do not like
Thanks
|
|
|
|
|
OK, I misunderstood, I was thinking of more basic electronic stuff.
you did not and still don't tell the make and model, the kind of interface, etc. so how could anyone offer real help?
if the interface is serial (RS232C) you should use the SerialPort class, and transmit/receive byte arrays. if the interface is something else (e.g. USB) you would need the manufacturer's driver.
As far as the commands and encryption go, your first reference should also be the manufacturer's documentation.
If in the end you have a specific question or problem, show some code, and someone will be able to help you.
|
|
|
|
|
If you're right about that, is something more at the programming level. Well if necessary, the manufacturer's documentation does not offer me much, except what I have outlined here. I am communicating by serial interface. Hopefully someone can help me. When communication was achieved by sending a byte array, however, to verify the PIN PAD communication do not operate if you do not send as a command EC is, I sent
02 67 69 48 03 <lrc>
STX C E 0 ETX <lrc>
06 And I get a response (ACK) on the device but not recognized as an instruction, told me I should send a command such as CE, I suppose that as a single byte, but not how to do
|
|
|
|
|
you still are keeping everything a secret except that you now told the world it is using a serial port.
What is the make and model?
what documentation do you have?
do you have their sample code?
do you have examples of messages?
where did you get those STX, ETX, ACK inspiration?
does it say anything about ENQ?
does it say anything about hardware handshake lines?
etc etc.
and why do you send CE and call it an EC command?????
|
|
|
|
|
Sorry luc
The information that I had not previously requested, but this time I can answer your questions.
1- It is a PINpas Secura (http://www.secure-retail.co.uk/products/index.php?sg=&manufacturer=all§ion=Terminals&range=Chip% 20and% 20PIN & pid = 1146)
2- The documentation I have is a small reference manual says that only the commands to be sent to the device but do not specify mas.Solo say "you have to send <stx> <ce0> <ext> <lrc>" They do not provide any other info.
3- The example code is
Public Sub SendData(ByRef strCadena As String, ByVal strType As String, ByVal LRC As String, ByVal strCaracterInicial As String, ByVal strcaracterFinal As String, Optional ByRef strComando As String = "")
Dim strNuevaCadena As String = "", nCount As Integer = 0
Try
If comm.OpenPort = True Then
comm.ClosePort()
comm.OpenPort()
End If
Catch
MsgBox("Error " & Err.Description, MsgBoxStyle.Critical + MsgBoxStyle.Exclamation, "Open Port")
comm.ClosePort()
comm = Nothing
End Try
Try
comm.Message = strCadena
If strType = "HEX" Then
comm.CurrentTransmissionType = clscommanager.TransmissionType.Hex
Else
comm.CurrentTransmissionType = clscommanager.TransmissionType.Text
End If
For nCount = 1 To Len(strCadena)
strNuevaCadena = strNuevaCadena & Asc(Mid(strCadena, nCount, 1))
Next
comm.Type = clscommanager.MessageType.Normal
comm.WriteData(strCaracterInicial, Asc(strComando), strNuevaCadena, strcaracterFinal, LRC)
Catch
MsgBox("Error " & Err.Description , MsgBoxStyle.Critical + MsgBoxStyle.Exclamation, "Open Port")
End Try
End Sub
Where strCadena ="CE1", strType = "HEX", LRC = Result LRC, strCaracterInicial = "STX", strcaracterFinal = "EXT", strComando = ????
4- STX EXT values etc. The got a page with ASCII values (http://i-logic.com/serial/ascii.htm)
5- What you mentioned is the following ENQ:
"The master must send an ENQ character (0x05) to be answered with an ACK character (0x06) with the PIN pad. This procedure indicates whether the PIN pad is ready to accept a request from the master device.
If no ACK is received from the PIN pad within the time-out period (default = 15 seconds), the master must send poll before sending the command.
The master must repeat the process of sending a pennyroyal ENQ command until an ACK is received within the period of time-out"
6- does it say anything about hardware handshake lines. No
7- When I started to program the service provider asaesorando me and I sent copies of the bytes being sent to the port. When you send in the final chain <stx> <ce0> <etx> <lrc> I said, "The calculation of the LRC's fine, "The problem is not sending these as CE0 or CE1 command"
String that I send is : 02 67 69 48 03 45. giH.E
I hope this helps you better ented
|
|
|
|
|