Electronics, PCB Design and PCB Layout Daycounter, Inc.
Engineering Services

Custom Firmware, Electronics Design, and PCB Layout

                 
 
Electronics Design
Firmware Development
Software Development
Embedded Design
PCB Layout
Digital Signal Processing (DSP)
Reverse Engineering
Prototyping
Device Driver Development
VHDL
Motor Controllers
Microcontrollers
Data Acquisition Systems
Palm OS Software
Windows CE Software
Pocket PC Software
Design for Manufacturing
Through Hole to Surface Mount (SMT) Conversion 
Microchip PIC Consultant
MSP430 Development
DSP56 Development
RoHs Redesign
Design for USB



Silver Board Contract Assembly


 

How to Open an RS232 Com Port in Visual C++

USB com ports are typically assigned port numbers greater than 9, which impacts how the CreateFile function must be called.  For COM numbers less than 9 CreateFile is called with a string such as: "COM1".  For numbers greater than 9, a prefix of "\\.\" must be added to the com port string, for example "\\.\COM24". Fortunately, the prefix can be added to ports below 9 as well, and so for consistency, just add the prefix to any comport string.  Since back slash is a escape special character they must be paired, in the code. 

hComPort= CreateFile("\\\\.\\COM24", GENERIC_READ |GENERIC_WRITE, 0, 0, OPEN_EXISTING, 0, 0);

if (hComPort == INVALID_HANDLE_VALUE){ 
   hComPort= 0;
   return (lastError= ERR_OPEN_COMM); /* Error! */
}

 

Daycounter specializes in contract electronics design.  Do you need some help on your project?  Contact us to get a quote. 

[Employment] [Downloads] [Articles] [Contact Us]

Salt Lake City, UT, USA

Disclaimer: Daycounter, Inc. doesn't guarantee the accuracy of any of it's content. Use at your own risk.

© Copyright 2016 Daycounter, Inc. All rights Reserved.






Soil Moisture Sensor Probe



Water Level Sensor