Re: Serial port communications with iPaq; max baud rate ?
From: A.B. (someone_at_somewhere.com)
Date: 05/01/04
- Next message: A.B.: "Re: Serial port communications with iPaq; max baud rate ?"
- Previous message: r_z_aret_at_pen_fact.com: "Re: Serial port communications with iPaq; max baud rate ?"
- Maybe in reply to: A.B.: "Re: Serial port communications with iPaq; max baud rate ?"
- Next in thread: A.B.: "Re: Serial port communications with iPaq; max baud rate ?"
- Reply: A.B.: "Re: Serial port communications with iPaq; max baud rate ?"
- Messages sorted by: [ date ] [ thread ]
Date: Sat, 1 May 2004 16:41:24 -0400
I have some code done but it doesn't work right... I get the following error
output oof my program (see source below):
GetCommState OK
Making custom settings...
Error setting COM state, error 437384220
-------------------------------------------Source
Code----------------------------------------------------------------
//*** GLOBAL VARIABLES ***
HANDLE hSerialPort; //for serial communications
DCB dcbPort; //Init the device control block (for serial port)
BOOL CSDOscopeDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
CenterWindow(GetDesktopWindow()); // center to the hpc screen
//open serial port (COM1)
hSerialPort = CreateFile(_T("COM1:"), GENERIC_READ | GENERIC_WRITE, 0,
NULL, OPEN_EXISTING, 0, NULL); //NOTE: I.R. comm = COM3:
//Init the settings for the dcbPort (device control block) structure
if(GetCommState(hSerialPort, &dcbPort) == false)
TRACE(_T("GetCommState Failed\n Can not use COM Port\n"));//debug message
else
{
TRACE(_T("GetCommState OK\n Making custom settings...\n"));//debug message
dcbPort.BaudRate = CBR_115200; //set baud rate
dcbPort.ByteSize = 8; //Set Bytes
dcbPort.Parity = NOPARITY; //Set Parity
dcbPort.StopBits = ONESTOPBIT; //Set stop bit
//Set the port state
if(SetCommState(hSerialPort, &dcbPort) != 0)
{
TRACE(_T("Error setting COM state, error %u\n",GetLastError()));//debug
message
}
else
TRACE(_T("COM state set OK\n"));//debug message
}
return TRUE; // return TRUE unless you set the focus to a control
}
"Al" <anonymous@discussions.microsoft.com> wrote in message
news:BC93706F-E3EB-42FF-8884-E5B6361C463B@microsoft.com...
> I'm connecting a microcontroller to the iPaq using the serial port (I
purchased a cable from HP that splits the proprietary 22pin connector into
USB & RS232 connections).
>
> There are just a few sticking points:
> 1) Using eVC++4 & MFC, how do I open a COM port?
> 2) the maximum baud rate of the iPaq serial port? I know this sounds like
a silly question, and a lot of people are going to think 115K, but the
microcontroller I'm using is capable of up to 2Mbaud... so I'm hoping the
iPaq 4155 doesn't stick to the antique 115K.
>
> THANKYOU!!
- Next message: A.B.: "Re: Serial port communications with iPaq; max baud rate ?"
- Previous message: r_z_aret_at_pen_fact.com: "Re: Serial port communications with iPaq; max baud rate ?"
- Maybe in reply to: A.B.: "Re: Serial port communications with iPaq; max baud rate ?"
- Next in thread: A.B.: "Re: Serial port communications with iPaq; max baud rate ?"
- Reply: A.B.: "Re: Serial port communications with iPaq; max baud rate ?"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|