Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

status_invalid_parameter noticed when sending a message to a serial port

Posted on 2006-10-20
14
Medium Priority
?
347 Views
Last Modified: 2012-06-21
I have an application that runs fine for quite a while.  At some point, this app which communicates using the serial port, begins to have issues.  Using a serial port sniffer, I noticed that when an 0x06 is sent out by my app (ACK), an "status_invalid_parameter" is displayed alongside the ACK in the sniffer's logs.  What might be causing this?
0
Comment
Question by:abcast
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 8
  • 6
14 Comments
 
LVL 7

Expert Comment

by:Mohamed Zedan
ID: 17783254
What device are you communicating with  ..
and how are you using the serial port... component,,, or custom built class?

what is the scenario of data between the application and the device when the error happens ?
0
 

Author Comment

by:abcast
ID: 17789722
The device is a 3rd-party device (not running Windows).  It's just a piece of hardware.  The client is running Windows2k, and was developed using C#.  I'm using the Windows API when I send a byte immediately, such as an ACK.  

When the error happens, it appears that the ACKs might not be getting through.  The device then repeats its responses for some time, since it probably never received an ACK.  
0
 
LVL 7

Expert Comment

by:Mohamed Zedan
ID: 17790808
I have dealt with access control devices , mobile phone, pbx machines... and alot more serial devices .. could you post how you are sending the ACK to the device ... Also I have used the comm control ,, windows api and the wounderfull sax communications component which was included for free in the vb.net resource kit... which is the easiest of all to use so please post the code you are using to send the ACK ...
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:abcast
ID: 17790833
SerialPort class:
            /// <summary>
            /// Sends a byte immediately ahead of any queued bytes.
            /// </summary>
            /// <param name="tosend">Byte to send</param>
            /// <returns>False if an immediate byte is already scheduled and not yet sent</returns>
            protected void SendImmediate(byte tosend)
            {
                  CheckOnline();
                  if (!Win32Serial.TransmitCommChar(hPort, tosend))
                  {
                        ThrowException("Send immediate failure");
                  }
                  GC.KeepAlive(this);
            }



Win32Serial class:
            [DllImport("kernel32.dll")]
            internal static extern Boolean TransmitCommChar(IntPtr hFile, Byte cChar);
0
 
LVL 7

Accepted Solution

by:
Mohamed Zedan earned 2000 total points
ID: 17791853
where do you set the port settings like com1 ,,, baudrate , databits, stopbit,parity ....

why don't you use WriteFile to send the char to the serial port ...
also have a look at this class

http://www.codeproject.com/dotnet/DotNetComPorts.asp
0
 

Author Comment

by:abcast
ID: 17791871
I do the settings in another area of the code, but that isn't causing a problem.

Why should I be using WriteFile?  What is the benefit of that vs TransmitCommChar?

I looked at the link quickly.  We may have problems using 3rd-party software like the one in the link.  Also, using that would require an extensive rewrite of my code, and I'd rather not do that.
0
 
LVL 7

Expert Comment

by:Mohamed Zedan
ID: 17792109
The link I provided isn't a 3rd party component it's an open source component...
as for writefile
writefile  allows to send a whole line of characters as well as single characters... it also allows for asynchronous writting to the serial port...

while transmitcommchar sends only one char and is synchronous...

and other than that I allways used writefile for all my work :))
please try that and tell me the result....
0
 

Author Comment

by:abcast
ID: 17792147
I only use TransmitCommChar to send that one byte.  I have switched to using writefile for sending the ACK byte.  I will run the app overnight and see what happens.

The reason I have been using TransmitCommChar is due to the fact that the device on the other end needs to receive the ACK within 1000 ms of sending its data.  If it doesn't receive it w/in 1000 ms, it re-transmits.  I wanted to make sure that the ACK got there in time, and I was under the impression that TransmitCommChar was the best way to do this.  
0
 
LVL 7

Expert Comment

by:Mohamed Zedan
ID: 17792173
well that's a nasty device ... what is it for ?
0
 

Author Comment

by:abcast
ID: 17796221
The device is pretty new, but the protocol is decades old.  The device is a video routing switcher.  I have tested using writefile against a simulator.  All I know is that is hasn't caused additional problems, since we are not able to reproduce this problem against a simulator.  I plan on connecting to the actual device tomorrow.  I will keep you posted.  Hopefully, I can put this issue to rest.

Any ideas as to why the TransmitCommChar call was resulting in this error after some time?
0
 
LVL 7

Expert Comment

by:Mohamed Zedan
ID: 17803265
I'll have to see the transmitcommchar function in the sdk ... hope to  find an explanation...
0
 
LVL 7

Expert Comment

by:Mohamed Zedan
ID: 17803323
that is what is said about the function in the SDK :

TransmitCommChar

The TransmitCommChar function transmits a specified character ahead of any pending data in the output buffer of the specified communications device.


BOOL TransmitCommChar(
  HANDLE hFile,
  char cChar
);

Parameters
hFile
[in] Handle to the communications device. The CreateFile function returns this handle.
cChar
[in] Character to be transmitted.
Return Values
If the function succeeds, the return value is nonzero.

If the function fails, the return value is zero. To get extended error information, call GetLastError.

Remarks
The TransmitCommChar function is useful for sending an interrupt character (such as a CTRL+C) to a host system.

If the device is not transmitting, TransmitCommChar cannot be called repeatedly. Once TransmitCommChar places a character in the output buffer, the character must be transmitted before the function can be called again. If the previous character has not yet been sent, TransmitCommChar returns an error.

I think the last part in the remarks is what is causing you the trouble.... but your sendimmediate function handles that case and throws an exception !??! well ... keep me posted to your progress :)
0
 

Author Comment

by:abcast
ID: 17850901
Looks like that did it.  The problem usually happens about 16 hours after the client is started.  It went 4+ days, and no problem reported yet.  Thanks!
0
 
LVL 7

Expert Comment

by:Mohamed Zedan
ID: 17851905
your welcome :)
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question