aldweb

Close I. aldweb

Close II. PC Freeware

Close III. Palm Freeware

Close IV. Palm Shareware

Close V. iziBasic Palm

Close VI. Palm Knowledge

Close VII. Pocket Computer

Close VIII. miniPortail

Special !



Mobile version of
the aldweb Site

m.aldweb.com


Neither French, nor English?

Try one of these flags then:
[de] [es] [it] [pt]
Search




Weather / Spam / www

Lyon Weather


aldweb against spam


Newsletter
To receive news about this website, consider subscribing to our Newsletter.
Subscribe
Unsubscribe
298 Subscribers
Family's web sites

Webmaster - Infos
Friends News
Visits

   visitors

   visitors online

Poll
What do you think of the new design of the aldweb Site?
 
Great !
Beautiful
Average
So ugly...
Results
forum.gifForum - iziBasic - Topic #1444

Forum - Forum
iziBasic - iziBasic


Warning: A non-numeric value encountered in /web5/aldweb/www/aldweb_com/www/thread.php on line 257

active  Topic # 1444  Any update on serial port?

20/08/2006 @ 18:55
by Pokey

Anonymous



I found a response from 2004 regarding the lack of serial port support with iziBasic. Is there any update on this? Would you like a Keyspan serial port adapter mailed to you for testing purposes?

Seems a shame not to have this feature on otherwise feature-rich product.
  Post an answer  Top

Warning: A non-numeric value encountered in /web5/aldweb/www/aldweb_com/www/thread.php on line 497
Answer n° 1
--------
21/08/2006 @ 10:21
by aldweb

Anonymous

visitor
Hello Pokey,

First of all, I have to thank you for searching and reading first this old post before asking.

The answer I provided back in November 2004 is still valid, as I did not dig into Palm's serial communications since then. Writing a so called "PP applet" would therefore be required at the time being.

And I would be interested if someone writes one and then accepts to share his code with me for this need, it would ease a lot my work afterwards to integrate serial communications in iziBasic.

Cheers,
aldweb
Write to aldweb   Post an answer  Top

Warning: A non-numeric value encountered in /web5/aldweb/www/aldweb_com/www/thread.php on line 497
Answer n° 2
--------
24/08/2006 @ 04:00
by Pokey

Anonymous

visitor
Hi,

I can't give you Pascal because I'm not a Pascal programmer. However, I just finished writing a serial routine in C and tested it tonight on my IIIxe. It sends "hello" 99 times and then waits 9 seconds for 1 byte.

Hopefully this may help you put it in iziBasic as coding in C is such a pain.

//*********************************************
//* Main routine
//*********************************************
int myMain() {
UInt16 iPort=0;
UInt32 iBytes=0;
UInt32 iLen=0;
UInt32 iCnt=0;
UInt16 iTicks=0;
UInt32 iErr=0;

Char caBuffer[64];
Char caOut[16];

Char *pcData;
Char *pcBuffer;

int i=0;
MemHandle h;

FrmCustomAlert(Alert1,"nStarting serial"," "," " );
iPort=openPort();

if(! iPort) {
FrmCustomAlert(Alert1,"Couldn't open the port"," ", " ");
return -1;
}

StrCopy(caBuffer,"Hellox0Dx0A"); //hello with CRLF

iLen=StrLen(caBuffer);

for(i=0; i < 99; i++) { //send 99 times for test

iBytes=sendToPort(iPort, caBuffer, iLen);

if(! iBytes) {
FrmCustomAlert(Alert1,"No bytes sent"," ", " ");
closePort(iPort);
return -1;
}
}

//wait 9 secs to receieve 1 byte of data

iTicks=9 * SysTicksPerSecond();

iErr=SrmReceiveWait(iPort, 1, iTicks);

if(iErr) {
printError(iErr);
return 0;
}

//check to see if data showed up on bus

if(! checkRecv(iPort, &iCnt)) { //check for any bytes on recv bus
closePort(iPort);
return -1;
}

if(iCnt) { //data available to read
h = MemHandleNew(iCnt+1); // iCnt = # bytes to get

if(h == 0) {
FrmCustomAlert(Alert1,"Couldn't obtain handle to memory"," ", " ");
closePort(iPort);
return -1;
}

pcBuffer= (Char *)MemHandleLock (h);

if(pcBuffer == NULL) {
FrmCustomAlert(Alert1,"Couldn't obtain pointer to memory"," ", " ");
closePort(iPort);
return -1;
}

if(! recvFromPort(iPort, pcBuffer, iCnt)) {
FrmCustomAlert(Alert1,"No bytes read"," ", " ");
closePort(iPort);
MemHandleUnlock(h);
MemHandleFree(h);
return -1;
}

StrNCopy(caOut,pcBuffer,iCnt);
caOut[iCnt+1]='';

FrmCustomAlert(Alert1,"Received a byte:",caOut," ");

MemHandleUnlock(h);
MemHandleFree(h);

}

closePort(iPort);

return 0;

}

//*********************************************
//* open the port
//* Returns: port # opened or 0 if fail
//*********************************************
UInt16 openPort() {
UInt32 iErr=0;
UInt16 iPort=0;

iErr=SrmOpen (serPortCradleRS232Port, 9600, &iPort); //9600 baud, default is 8N1

if(iErr) {
printError(iErr);
return 0;
}

return iPort;
}

//**********************************************
//* check the receive buffer
//*
//* Parms: iPort - port #
//* piCnt - Pointer to integer which will
//* contain number of bytes ready.
//* Returns: 1 on success, 0 on failure
//**********************************************
UInt32 checkRecv(UInt16 iPort, UInt32 *piCnt) {

UInt32 iErr=0;

iErr=SrmReceiveCheck (iPort, piCnt);


if(iErr) {
printError(iErr);
return 0;
}

return 1;
}


//**************************************************
//* receive data from port
//*
//* Parms: iPort - port #
//* caData - pointer to Char buffer to place
//* data received
//* iCnt - length of receive buffer pcData
//* Returns: # bytes received
//**************************************************
UInt32 recvFromPort(UInt16 iPort, Char *pcData, int iRecCnt) {

UInt32 iErr=0;
UInt16 iTicks;
UInt32 iCnt=0;

iTicks=5 * SysTicksPerSecond();
iCnt=SrmReceive (iPort, (void *)pcData, iRecCnt, iTicks, &iErr); //ticks is timeout

if(iErr) {
printError(iErr);
return 0;
}

return iCnt;
}


//**********************************************
//* send data to port
//*
//* Parms: pcData - Pointer to data to send
//* iCnt - # of bytes to send
//* Returns: # bytes actually sent or -1 if fail
//**********************************************
UInt32 sendToPort(UInt16 iPort, Char *pcData, int iCnt) {

UInt32 iBytes=0;
UInt32 iErr=0;

iBytes=SrmSend (iPort, (void *)pcData, iCnt, &iErr);

if(iErr) {
printError(iErr);
return 0;
}

return iBytes;
}


//*********************************************
//* close the port
//*********************************************
UInt16 closePort(UInt16 iPort) {

UInt32 iErr=0;

iErr=SrmClose (iPort);

if(iErr) {
printError(iErr);
return 0;
}

return 1;
}


//*********************************************
//* Print serial error codes.
//* Parms: iErr the error # to check
//* Returns: Nothing
//*********************************************
void printError(int iErr) {

Char caErr[99];

switch(iErr) {
case 0:
break;
case serErrBadParam:
FrmCustomAlert(Alert1,"Parm exceeds size of th
  Post an answer  Top

Warning: A non-numeric value encountered in /web5/aldweb/www/aldweb_com/www/thread.php on line 497
Answer n° 3
--------
26/08/2006 @ 20:40
by aldweb

Anonymous

visitor
Hello Pokey,

Your message was truncated because I have put a limit in terms of allowed number of characters to avoid overflow on my web site.

Would you please send me the source code by e-mail? Thank you.

Cheers,


@+
aldweb
Write to aldweb   Post an answer  Top
active topic active   closed topic closed   Sticky Sticky   New New message   -   Correct Correct message   Close Close topic   Make sticky Make sticky
[]
Forum Topic  Forum 



 
^ Top ^