Page 1 of 1

PostPosted: Fri Oct 17, 2003 10:50 am
by ahkub
Hi there,
after the huge success of my last question (database sorting), I have another one which I don't expect to see any answers: ;)

Does anybody know if PocketC can handle virtual com ports com7 and com8?
I'd like to read serial data (9600 bps) from a bluetooth GPS via SPP and read it into PocketC.

Best Regards,
Alf

PostPosted: Tue Mar 09, 2004 2:43 pm
by Brendan Donovan
Hi Alf,

Don't know if this is still of interest to you, but I have used PocketC to communicate with a serial bluetooth device on the virtual com ports.

There were two main issues in getting it to work.(I assume you are using an iPAQ based on your reference to com7 and 8)

1) After connecting to the bluetooth device in bluetooth manager, you actually need to send and receive on com8 despite what the iPAQ documentation says about sending on one and receiving on the other.

2) The pocketC serial functions did not work for com8. I had to download the PocketC wince api from http://www.networkdynamics.net/PCForm.html#library , and use CreatFile() rather than seropen().

Below is the section of code adapted from the serial example on the orbworks site. -brendan
-----------

SetLastError(0);
portName="COM8:";

// instead of seropen
ret=CreateFile(portName, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);

//// set parameters

//get current parameters
if(! GetCommState(ret, &rDCB)){
confirm("Error getting comm state " + GetLastError());
CloseHandle(ret);
quit();
}

//Change parameters
rDCB.BaudRate=9600;
rDCB.fParity=FALSE;
rDCB.ByteSize=8;
rDCB.Parity=NOPARITY;
rDCB.StopBits=ONESTOPBIT;
rDCB.fOutxCtsFlow=FALSE;
rDCB.fRtsControl=FALSE;
rDCB.fOutxDsrFlow=FALSE;
rDCB.fDsrSensitivity=FALSE;
rDCB.fDtrControl=FALSE;
rDCB.fOutX=FALSE;
rDCB.fInX=FALSE;
rDCB.fAbortOnError=FALSE;

//Write parameters
if(!SetCommState(ret,&rDCB)){
confirm("SetCommState faile " + GetLastError());
CloseHandle(ret);
quit();
}


//confirm("open error was " + GetLastError());
putsl("Seropen returned: "+ret);
putsl("Successful serial port initialization returns a non zero integer.");

commsetmask(ret,EV_RXCHAR); // generate comm interrupt on character inputs.

PostPosted: Wed May 19, 2004 10:09 am
by ahkub
Thanks, Brandon, looks promising. I'll give it a try!:|