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 - serial port i/o source code examples

serial port i/o source code examples

Postby cavlon99 on Tue Jan 13, 2004 4:08 am

We just bought the palm os pocket c and want to use the palm serial port. Can someone point us to source code examples of writing to and reading from the serial port with pocket c?

Best regards,
Charles

cvl
cvl
cavlon99
 
Posts: 2
Joined: Tue Jan 13, 2004 4:03 am
Location: USA

Postby shayneham on Tue Jan 13, 2004 3:26 pm

Search the archives, I know I have seen plenty of serial port code posted in the past. Here are two functions I wrote and used for a couple weeks before abandoning them for a different method of sending information to and from my desktop program. Since I am now more of a lurker than an active PocketC programer I only come by here so often, so any questions for me will take a bit before they are answered.


This function connects to a desktop program I made and transfers information from a database.

exportJob(){
int loc,ret,len,recCnt;
string retVal;
string DBname,chunk,emptyString;
char dataEmpty[500],dataOut[500],ProgCheck[7],LineFeed;
emptyString = ctostr(&dataEmpty);
loc = Cgetcursel(lbJobList);
if (loc == -1){
alert("You must first select a job from the list");
return 0;
} else {
DBname = "QXP_"+Cgetcontent(lbJobList);
if (!dbopen(DBname)){
alert("The selected Job could not be opened for export.");
retVal = seropenx(0x8000,57600);
if (retVal == 0){
chunk = "QxpPalmExport";
len = strlen(chunk);
strtoc(chunk,&dataOut);
sersenda(&dataOut,len);
strtoc(emptyString,&dataOut);
retVal = serwait(7,100);
if (retVal == 1){
serrecva(&ProgCheck,7);
chunk = ctostr(&ProgCheck);
if (chunk == "QxpDesk"){
//communication properlly establised with the desktop program
recCnt = dbnrecs();
chunk = DBname + "`" + (string)recCnt + "~";
len = strlen(chunk);
strtoc(chunk,&dataOut);
sersenda(&dataOut,len);
strtoc(emptyString,&dataOut);
retVal = serwait(1,100);
serrecva(&LineFeed,1);
chunk = (string)LineFeed;
if (chunk == "~"){
//now step through the records and send them one at a time using ` between values
RecNum = 1;
while (RecNum <= recCnt){
dbrec(RecNum-1);
dbreadx(&retVal, "sz");
chunk = retVal;
dbreadx(&retVal, "sz");
chunk = chunk + "`" + retVal;
dbreadx(&retVal, "sz");
chunk = chunk + "`" + retVal;
dbreadx(&retVal, "sz");
chunk = chunk + "`" + retVal;
dbreadx(&retVal, "sz");
chunk = chunk + "`" + retVal;
dbreadx(&retVal, "sz");
chunk = chunk + "`" + retVal;
dbreadx(&retVal, "sz");
chunk = chunk + "`" + retVal;
dbreadx(&retVal, "sz");
chunk = chunk + "`" + retVal;
dbreadx(&retVal, "sz");
chunk = chunk + "`" + retVal;
dbreadx(&ret, "i2");
chunk = chunk + "`" + (string)ret;
dbreadx(&ret, "i2");
chunk = chunk + "`" + (string)ret;
dbreadx(&ret, "i2");
chunk = chunk + "`" + (string)ret;
dbreadx(&ret, "i2");
chunk = chunk + "`" + (string)ret;
dbreadx(&ret, "i2");
chunk = chunk + "`" + (string)ret;
dbreadx(&ret, "i2");
chunk = chunk + "`" + (string)ret;
dbreadx(&ret, "i2");
chunk = chunk + "`" + (string)ret;
dbreadx(&ret, "i2");
chunk = chunk + "`" + (string)ret;
dbreadx(&ret, "i2");
chunk = chunk + "`" + (string)ret;
dbreadx(&ret, "i2");
chunk = chunk + "`" + (string)ret;
dbreadx(&ret, "i2");
chunk = chunk + "`" + (string)ret;
len = strlen(chunk);
strtoc(chunk,&dataOut);
sersenda(&dataOut,len);
strtoc(emptyString,&dataOut);
sersend("~");
retVal = serwait(1,100);
serrecva(&LineFeed,1);
chunk = (string)LineFeed;
if (chunk == "~"){
RecNum++;
}
}//end while
sersend("~");
sersend("~");
retVal = serwait(1,100);
serrecva(&LineFeed,1);
chunk = (string)LineFeed;
if (chunk == "~"){
alert("Export has been succesful.");
serclose();
dbclose();
} else {
dbclose();
serclose();
alert("Problem occured at end of export..."+retVal+chunk);
}
} else {
dbclose();
serclose();
alert("~ not returned as expected..."+retVal+chunk);
}
} else {
dbclose();
serclose();
alert("The serial connection recieved improper date: "+chunk);
}
} else {
dbclose();
serclose();
alert("Serial connection has taken to long to recieve information: "+(string)retVal);
}
} else {
alert ("Could not open the serial port, please make sure your Handheld device is properly seated in its cradle.");
}
}
}
serclose();
}



This code transfers information from the desktop computer into a database, all via serial port of course...

importQxpInfo(){
int loc,ret,len,recCnt,fieldNum;
string retVal,temp;
string DBname,chunk,emptyString;
char dataEmpty[500],dataOut[500],ProgCheck[7],LineFeed;
emptyString = ctostr(&dataEmpty);
retVal = seropenx(0x8000,57600);
if (retVal == 0){
chunk = "QxpPalmImport";
len = strlen(chunk);
strtoc(chunk,&dataOut);
sersenda(&dataOut,len);
strtoc(emptyString,&dataOut);
retVal = serwait(7,100);
if (retVal == 1){
serrecva(&ProgCheck,7);
chunk = ctostr(&ProgCheck);
if (chunk == "QxpDesk"){
//communication properlly establised with the desktop program
retVal = dbcreatex("QxpInfo","Skha","prvt");
if (retVal == 0){
alert("There was a problem creating a Database to store the informaton.");
}
//Database is now created, start recieving Wrap and Liner Info
retVal = serwait(1,1500);//wait up to 15 seconds
if (retVal == 1){ //cause desktop is creating
serrecva(&LineFeed,1);//the list to be sent to palm
chunk = (string)LineFeed;
if (chunk != "~"){
alert("Error while waiting for desktop to create info to be Imported.");
}
}
recCnt = 1;
while (recCnt <= 6){
fieldNum = 1;
dbrec(recCnt-1);
while (fieldNum <= 22){
temp = "";
ret = 1;
sersend("~"); //tell QxpDesktop to send the next value
while (ret == 1){
if (serwait(1,100) == 1) {
serrecva(&LineFeed,1);
chunk = (string)LineFeed;
if (chunk == "~"){
ret = 0;
} else {
temp = temp + chunk;
}
} else {
ret = 0;
}
} //end while receive
//Csetcontent(btnDeleteJob,temp);
//Cdraw(btnDeleteJob); //for Testing purposes
dbwritex(&temp,"sz");
fieldNum++;
} //end while field
recCnt++;
} //end while record
//Wrap and Liner info done
dbclose();
//Start receiving Setup and PF info
retVal = dbcreatex("QxpPfInfo","Skha","prvt");
if (retVal == 0){
alert("There was a problem creating a Database to store the informaton.");
}
//Database is now created, start recieving PF info
recCnt = 1;
while (recCnt <= 10){
fieldNum = 1;
dbrec(recCnt-1);
while (fieldNum <= 161){
temp = "";
ret = 1;
sersend("~"); //tell QxpDesktop to send the next value
while (ret == 1){
if (serwait(1,100) == 1) {
serrecva(&LineFeed,1);
chunk = (string)LineFeed;
if (chunk == "~"){
ret = 0;
} else {
temp = temp + chunk;
}
} else {
ret = 0;
}
} //end while receive
dbwritex(&temp,"sz");
fieldNum++;
} //end while field
recCnt++;
} //end while record
//Wrap and Liner info done
dbclose();
sersend("~");
sersend("~");
retVal = serwait(1,100);
serrecva(&LineFeed,1);
chunk = (string)LineFeed;
if (chunk == "~"){
alert("Import has been succesful.");
serclose();
dbclose();
fillWrapLinerArrays();
} else {
dbclose();
serclose();
alert("Problem occured at end of import..."+retVal+chunk);
}
} else {
dbclose();
serclose();
alert("The serial connection recieved improper date: "+chunk);
}
} else {
dbclose();
serclose();
alert("Serial connection has taken to long to recieve information: "+(string)retVal);
}
} else {
alert ("Could not open the serial port, please make sure your Handheld device is properly seated in its cradle.");
}
serclose();
}


Hope this helps somewhat.

Shayne


Shayne Hamel
Quote Software
shayneham@attbi.com
Shayne Hamel
Quote Software
shayneham
 
Posts: 52
Joined: Thu Sep 19, 2002 7:48 pm
Location: USA

Postby cavlon99 on Tue Jan 13, 2004 8:25 pm

Shayne,

Thanks so much for the reply. I know there has been a lot in the past but I have not been able to find archives to search that contian "serial" anything.

Any idea where to find old archives?



Best regards,
Charles

cvl
cvl
cavlon99
 
Posts: 2
Joined: Tue Jan 13, 2004 4:03 am
Location: USA

Postby cable_guy_67 on Tue Jan 13, 2004 8:46 pm

At the top right of the page hit the search link. When prompted enter 'serial' with all forums chosen. You will get 12 pages of topics.

Mark
cable_guy_67
 
Posts: 92
Joined: Mon Mar 31, 2003 2:28 am
Location: USA

Postby otakribut1 on Tue Apr 19, 2005 2:07 am

i've seen sersenda("") in the above codes.
but this sersenda doesn't work on pocket for pocketpc?
is it the same as sersend(..)
otakribut1
 
Posts: 12
Joined: Tue Feb 22, 2005 2:26 am


Return to PocketC for Palm OS KB

Who is online

Users browsing this forum: No registered users and 4 guests

cron