Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3368: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:472)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3370: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:472)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3371: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:472)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3372: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:472)
OrbWorks Community Forum • View topic - Help, GPS problems!
Page 1 of 1

PostPosted: Mon Sep 23, 2002 11:03 pm
by slick13
I am trying to open Com4 on my Ipaq to a Teletype GPS flash card using seropenex and seropen.
However when I try opening it the serial handle that is returned is always zero.
It works fine on Com1, 2 and 3 giving a number as the handle.
Without the handle I cant read any data from it using the readint() readbyte() etc. functions because they all need the handle to work.

Any help please.

PostPosted: Tue Sep 24, 2002 8:00 am
by guy
Call GetLastError() after the open fails to see what the error was.

<pre id="code"><font face="courier" size="2" id="code">


// At the top of your program


#export pcktceapi(30) GetLastError() ;
#export pcktceapi(83) SetLastError(int) ;


// In your code where you open the port


SetLastError(0) ;


// Do the open, then


confirm("Open error was " + GetLastError()) ;


</font id="code"></pre id="code">


Post the error that you get here.

You'll need to install the interface library to call the last error functions. Kevin doesn't provide them in the standard library (although strangely he references them from the standard library documentation).



Guy
[url]mailto:pcform@pcform.net[/url]
http://www.pcform.net
PocketC CE API interface: http://www.networkdynamics.net/PCForm.html#library
PCForm and CE API forum: http://www.networkdynamics.net/forum

PostPosted: Tue Sep 24, 2002 3:45 pm
by slick13
Tried that code.
Got an error of 87 after I tried to open com4.

By the way this might be useful, there is a little LED on the card which flashes when in stand by mode.It comes on when the serexopen() is called indicating something is happening because this is what happens in other pieces of software when the card tries an intial lock on its global position.

PostPosted: Wed Sep 25, 2002 8:17 am
by guy
Error 87 is "Invalid parameter". It is quite possible that the settings for the parameters that are wrong is out of your control when you use seropenex(). The PocketC library function may not configure elements of the device the way that you want.

You can determine this fairly easily. All you have to do is to replace the seropenex() function call with the calls to the actual API functions that seropenex() calls, with a check of GetLastError() after each function:

<pre id="code"><font face="courier" size="2" id="code">


// Code edited after first posting to board to fix fDsrSensitivity field name


#include "/pocketc/winbase.h"


// iHandle = seropenex("COM4:", iBaud, sSettings, 0) ; // Old function call


// First open the comms device


SetLastError(0) ;


iHandle = CreateFile("COM4:", GENERIC_READ | GENERIC_WRITE, 0, 0, OPEN_EXISTING, 0, 0) ;


if (iHandle == INVALID_HANDLE_VALUE) {
confirm("COM4: open failed with error " + GetLastError()) ;
quit() ;
}


// Now set the properties


DCB rDCB ; // Declare a device control block


// First get the current settings


if ( ! GetCommState(iHandle, &rDCB)) {
confirm("GetCommState failed with error " + GetLastError()) ;
CloseHandle(iHandle) ;
quit() ;
}


// Now change the ones that we want.
// DTR/DSR hardware device ready/unready flow control
// CTS/RTS hardware device buffer management flow control
//
// Example enables 8 bit, no parity, 1 stop bit, partial
// modem control and hardware flow control


rDCB.BaudRate = iBaud ;
rDCB.fParity = FALSE ; // Or whatever you want
rDCB.ByteSize = 8 ; // 8 bit characters
rDCB.Parity = NOPARITY ; // No parity
rDCB.StopBits = ONESTOPBIT ; // One stop bit
rDCB.fOutxCtsFlow = TRUE ; // Output hardware flow control with CTS
rDCB.fRtsControl = RTS_CONTROL_HANDSHAKE ; // Handshake RTS/CTS
rDCB.fOutxDsrFlow = TRUE ; // Output hardware "flow" control with DSR
rDCB.fDsrSensitivity= FALSE ; // Accept input even when DSR not set
rDCB.fDtrControl = DTR_CONTROL_ENABLE ; // Turn on DTR unconditionally
rDCB.fOutX = FALSE ; // Don't use output xon/xoff flow control
rDCB.fInX = FALSE ; // Don't use input xon/xoff flow control
rDCB.fAbortOnError = FALSE ; // Don't lock device on errors


// Now write the properties back


if ( ! SetCommState(iHandle, &rDCB)) {
confirm("SetCommState failed with error " + GetLastError()) ;
CloseHandle(iHandle) ;
quit() ;
}


// If you're here you can carry on with the code as it was before.
// The handle returned by seropenex() is the same as the handle
// returned by CreateFile() (so I'm informed).


</font id="code"></pre id="code">


If you get an error at any stage then post back.



Guy
[url]mailto:pcform@pcform.net[/url]
http://www.pcform.net
PocketC CE API interface: http://www.networkdynamics.net/PCForm.html#library
PCForm and CE API forum: http://www.networkdynamics.net/forum

PostPosted: Thu Sep 26, 2002 12:12 am
by slick13
Doh!
Failed at the first hurdle.
"COM4: open failed with error 55"
So its failing in the createfile function.
"IHandle" returns as -1 I assume this just flags a fail.
Made a small change to code "fOutDsrSensitivity" to "fDsrSensitivity".

PostPosted: Thu Sep 26, 2002 7:05 am
by guy
Error 55 (from the real winerror.h):

<pre id="code"><font face="courier" size="2" id="code">


//
// MessageId: ERROR_DEV_NOT_EXIST
//
// MessageText:
//
// The specified network resource or device is no longer
// available.
//
#define ERROR_DEV_NOT_EXIST 55L // dderror


</font id="code"></pre id="code">

I slowly working on producing a winerror.h for CEAPI, but the thing is vast and I'm not sure whether a subset would be any use.

I think -1 is INVALID_HANDLE_VALUE.

Apologies for the fDsrSensitivity thing. Fingers working faster than brain whilst typing.

Looks like your device isn't on COM4:

It also looks like the "Invalid Parameter" in seropenex() is actually the file handle. Perhaps Kevin tries to setup the comm port after the open without checking for the status of the call to CreateFile(). Or maybe he's checking for 0 as a fail status instead of INVALID_HANDLE_VALUE.

Guy
[url]mailto:pcform@pcform.net[/url]
http://www.pcform.net
PocketC CE API interface: http://www.networkdynamics.net/PCForm.html#library
PCForm and CE API forum: http://www.networkdynamics.net/forum

PostPosted: Mon Sep 30, 2002 1:01 pm
by slick13
Sorry didnt reply sooner.
Finally I got a heart beat.
Its seems it did give a file handle after all but after your if statement after the intial fileopen() it lost it.
Anyway my problem now is reading the data.
I am using a similar type of function to the serial chat example, in that I am waiting for a commevent and then using readbytes to read in the data in continious while.
There is however a problem if the varible is char that the data is copied into it comes in funny x's and square charcters, like an extended ASCII character set. When I change this to int the data comes in numbers ranging from 0 to 255.
Also I have noticed that the data doesnt seem to be coming in fast enough to equate to 1sec update which is what the GPS is set to.
Can PocketC keep up real time? Is there some way of maybe coping directly to machine memory?
Any suggestions?

PostPosted: Mon Sep 30, 2002 1:49 pm
by guy
What lost the file handle? Did you make sure that you used a double equals sign in the test in the if? (Otherwise it is an assignment).

You can bypass the PocketC serial communications functions and call the operating system functions directly to read into a real memory buffer. You'll lose the access to PM_COMMEVENT, but you can set timeouts on the reads in milliseconds so that your application can do other processing if nothing is read within a particular time.

The characters that you get may well be non-printable with the standard PocketC functions. Even carriage return and linefeed appear as square blobs in most of the output functions.

A good place to look at serial comms in Windows CE is:

http://msdn.microsoft.com/library/en-us/wcecomm/htm/_wcesdk_serial_communications.asp

The table of contents should open in the left hand pane so that you can navigate around the various serial sections.

You should note that you can't start additional threads in PocketC yet (still waiting for an update from Kevin), so you have to use ReadFile() with timeouts (SetCommTimeouts()) rather than in a separate thread. The CE API interface uses a real memory buffer for ReadFile() and WriteFile(), you'll need to use the mem*() functions (see the readme) to access the buffer, you can create the buffer with LocalAlloc().

Guy
[url]mailto:pcform@pcform.net[/url]
http://www.pcform.net
PocketC CE API interface: http://www.networkdynamics.net/PCForm.html#library
PCForm and CE API forum: http://www.networkdynamics.net/forum