473,396 Members | 1,764 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

C# program: Gettign 126 error while send data to Serial Port .?


Hi all,
I have a problem to communicate with serial port(COM3:). I am able to open
the handle but cannot send any data.

1. I connected my motoroala handset to PC through datacable.
2. I installed valid driver to detec the motorla(V400) handset
3. I tested the handset through Hypertermal and succssfully sending any
data.
4. I opened the Control Panel -> Phone and Model window and clicked the
modem tab and I saw that the Motorola handset( Motorola USB modem ) is
attached through COM3: port fo the PC
5. Then I created a sample C# program to communicate with handeset
through COM3 port . the code is like this:

handleName = "COM3:"
string text = "AT+CKPD=";
int byteCnt = oEnc.GetByteCount( text.ToCharArray(),0,text.Length,true);
byte[] Buffer = new byte[byteCnt];
int byteEncodeCount = oEnc.GetBytes(
text.ToCharArray ),0,text.Length,Buffer,0,true);
hSerialPort = Serial.CreateFile( handleName, Serial.GENERIC_READ |
Serial.GENERIC_WRITE, 0 ,IntPtr.Zero,
Serial.OPEN_EXISTING, Serial.FILE_FLAG_OVERLAPPED, IntPtr.Zero );
if( hSerialPort.ToString() == "-1" )
{

Console.WriteLine( "Un available");
}

int ch = 1;
if( ch == 1 )
Success = Serial.WriteFile( hSerialPort,Buffer,
Buffer.Length, out BytesWritten, IntPtr.Zero );

When i debug the code the Serial.WriteFile method is return false
value. and I got the system error code using Marshal.GetLastwin32Error(), it
is giving 126 error code. I searched in internet description of the 126
error , it says module not found.
I don't know what to do. I am imporing only Kernel32.dll in my sample
program. is anything i have to do..?
please help me on the problem..

Thanks & Regards
kiran kumar
ve*********@gmail.com
--

|\/\/\/\/\/|
| | V.V.P.C.K Kiran Kumar
| (o)(o)
c _)
----------------------------------------------------------------------------
----
Nov 17 '05 #1
1 2532
should you be opening "COM3:" or just "COM3"?
Nov 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Dan | last post by:
I wnat to see in browser an status from an device connected on rs232 port The java class for read from serial port is: //Serial.java import java.io.*; import java.util.*; import...
1
by: OZ | last post by:
the serproxy claim itself a multi-thread proxy thing. I have sent email to write the original writer and there is no replay after 3 weeks. my configuration and setting are good. ...
0
by: Tom | last post by:
I am new to hardware programming. I need to write a program for reading data from Card Reader which connects to the PC windows 2000/XP OS through Interfacing The Serial / RS-232 Port / USB /...
6
by: Ken | last post by:
When running a program in the debugger, what would cause it to crash without any error messages? I get "The program has exited with code 0 (0x0)". The program is a MDI app with threading for...
1
by: verge | last post by:
hello everyone! how's it going? like everyone in here im in need of some help and good friendship along the way...take a look at this: //MODIFIED SO IT DEALS WITH WINDOWS FTP USING ACTIVE...
2
by: Lou | last post by:
I have a class that creates an instance of the seril Port. Every thing works fine except whenever I receive data I cannot display the recieved data. I get no errors but the recived data seems to...
3
by: John Dann | last post by:
Trying to learn Python here, but getting tangled up with variable scope across functions, modules etc and associated problems. Can anyone advise please? Learning project is a GUI-based...
4
by: JDS | last post by:
I have an application that interfaces with a USB device using the .Net serial port. The code works fine, displaying live data on the screen; that is until the USB lead is pulled out from the PC...
1
by: lutherchp | last post by:
A baffling end to my week! I open my serial port on my Debian PC (Debian version 5.0.1) I have a decent Null Modem lead going to another PC (I'll call it PC#2), with its port open with the same...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.