This could be off topic (first post)...

I have a CF GPS driver for my clie (nx70-v), which shows in the connection 
manager and I can create a new connection using it.  I'd like to access the GPS 
device on the serial port and receive data from it.  using srmopen(),getting 
the portID from the connection manager and opening the port works and I can see 
the GPS initialize.  When I try to receive data or check the buffer it gives a 
srmStatusBreakSigOn error and I don't seem to be able to do anything to the 
port except close it.  

I have a eval copy of 'online' (generic serial/telnet device) which is able to 
receiver but seems to connect directly using the virtual serial driver (not 
100% sure about this).  I saw a posting from someone at mark/space.com on a 
driver issue a while ago...can you help

I've tried everything to get data out that I can think of but am completely 
stumped.  anyone please got any pointers.  Does it need to be initialised or 
something.  Even sending control signals fails with an error...

I've included my open, close and checkport() code.

#define myCustomSerQueueSize 32000 

Char            buffer[1024];           // serial buffer.
int             iCounter;

void *customSerQP; //my custom queue

UInt16 globalPortRef;
SrmOpenConfigType config;

void openGPSPort(UInt16* portRef)
{
        Err     err;
        UInt32 port;
        UInt32 baud;
        UInt16 paramSize;
        CncProfileID profileID;
        char message[20];
        
        MemSet (&config, sizeof (config), 0);
    config.baud         = 4800;
    config.function     = serFncUndefined;
        
        err=CncProfileGetIDFromName("GPS",&profileID);
        //get the baud rate
        //paramSize=kCncParamBaudSize;
        //err= CncProfileSettingGet(profileID,kCncParamBaud,&baud,&paramSize);
        
        //get the port number
        paramSize=kCncParamPortSize;
        err= CncProfileSettingGet(profileID,kCncParamPort,&port,&paramSize);
        
        err=SrmExtOpen(sysFileCVirtRfComm,&config,sizeof(config),portRef);
        
        //err = SrmOpen(port, 4800, portRef);
        if (err)StrPrintF(message, "%s", "error:port open");
        else StrPrintF(message, "%s", "port opened");
        WinDrawChars(message, StrLen(message), 10, 10);
                
        //now set the custom buffer
        // Allocate a dynamic memory chunk for our custom receive  
        // queue. 
        customSerQP = MemPtrNew(myCustomSerQueueSize); 
        // Replace the default receive queue. 
        if (customSerQP) { 
                err = SrmSetReceiveBuffer(*portRef, customSerQP, 
myCustomSerQueueSize); 
                if (err)
                {
                        SrmClearErr(*portRef);
                        if (err)StrPrintF(message, "%s", "error:receivebuffer");
                        
                }
                else StrPrintF(message, "%s", "buffer set");
                        WinDrawChars(message, StrLen(message), 10, 20);
        } 
        
        
}

static void closePort(UInt16 portRef)
{
                Err err;
                char message[20];
                
                // Now restore default queue and delete custom queue. 
                // Pass NULL for the buffer and 0 for bufSize to restore the  
                // default queue. 
                err = SrmSetReceiveBuffer(portRef, NULL, 0); 
                if (err)
                {
                        StrPrintF(message, "%s", "error:buffer reset");
                        WinDrawChars(message, StrLen(message), 10, 30);
                }
                StrPrintF(message, "%s", "buffer reset");
                WinDrawChars(message, StrLen(message), 10, 40);

                if(customSerQP) 
                { 
                        MemPtrFree(customSerQP); 
                        customSerQP = NULL; 
                }                               
                StrPrintF(message, "%s", "pointer reset");
                WinDrawChars(message, StrLen(message), 10, 50);
                
                err=SrmClose(portRef);
                if (err)StrPrintF(message, "%s", "error:port reset");
                else StrPrintF(message, "%s", "port reset");
                
                WinDrawChars(message, StrLen(message), 10, 60);
}

void checkPort(UInt16 portRef)
{
        Err err;
        UInt32 bytes;
        UInt32 toSend, numSent; 
        Char msg[] = "open\n";
        UInt32 timeout; 
        UInt32 status;
        UInt16 lineErrs;
        
        char message[20];
        
        err=SrmSendFlush(portRef);  
        
        //toSend = StrLen(msg); 
        //numSent = SrmSend(portRef, "open\n", 6, &err); 
        //if (err == serErrTimeOut) 
        //{
        //      StrPrintF(message, "%s", "error send"); 
        //}
        //else
        //      StrPrintF(message, "%d",numSent); 
                
        //WinDrawChars(message, StrLen(message), 10*iCounter, 80);
        
        err=SrmControl(portRef,srmCtlStopBreak,NULL,NULL);
        if (err) StrPrintF(message, "%s", "breakerror");
        WinDrawChars(message, StrLen(message), 10*iCounter, 70);
        
        err=SrmControl(portRef,srmCtlIrDAEnable,NULL,NULL);
        if (err) StrPrintF(message, "%s", "IrDAError");
        WinDrawChars(message, StrLen(message), 10*iCounter, 75);
        
        bytes=100;
        timeout=1000;
        err= SrmReceiveWait (portRef,bytes,timeout);
        if (err=serErrBadPort) StrPrintF(message, "%s", "This port doesn't 
exist."); 
        if (err=serErrNotOpen ) StrPrintF(message, "%s", "The port is not open. 
"); 
        if (err=serErrTimeOut)  StrPrintF(message, "%s", "receive timeout."); 
        if (err=serErrNotSupported ) StrPrintF(message, "%s", "not the 
foreground port"); 
        if (err=serErrBadParam ) StrPrintF(message, "%s", "bytes parameter 
exceeds "); 
        if (err=serErrLineErr )
        {
                StrPrintF(message, "%s", "line error"); 
                WinDrawChars(message, StrLen(message), 10*iCounter, 80);
                
                err=SrmGetStatus (portRef,&status,&lineErrs);
                if (status=srmStatusCtsOn) StrPrintF(message, "%s", "CTS line 
is active."); 
                if (status=srmStatusRtsOn) StrPrintF(message, "%s", " RTS line 
is active.  "); 
                if (status=srmStatusDsrOn)      StrPrintF(message, "%s", "DSR 
line is active."); 
                if (status=srmStatusBreakSigOn) StrPrintF(message, "%s", "Break 
signal is active."); 
                //if (status=srmStatusDtrOn) StrPrintF(message, "%s", "DTR is 
active."); 
                //if (status=srmStatusDcdOn) StrPrintF(message, "%s", "DCD is 
active.");         
                //if (status=srmStatusRingOn) StrPrintF(message, "%s", "Ring 
detected.");
                WinDrawChars(message, StrLen(message), 10*iCounter, 90);
                
                if(lineErrs=serLineErrorParity)StrPrintF(message, "%s","Parity 
error");
                if(lineErrs=serLineErrorHWOverrun)StrPrintF(message, 
"%s","Hardware overrun");
                if(lineErrs=serLineErrorFraming)StrPrintF(message, 
"%s","Framing error");
                if(lineErrs=serLineErrorBreak)StrPrintF(message, "%s","Break 
signal asserted");
                if(lineErrs=serLineErrorHShake)StrPrintF(message, "%s"," Line 
handshake error");
                if(lineErrs=serLineErrorSWOverrun)StrPrintF(message, 
"%s","Software overrun");
                if(lineErrs=serLineErrorCarrierLost)StrPrintF(message, 
"%s","Carrier detect signal dropped");
                WinDrawChars(message, StrLen(message), 10*iCounter, 100);
                
        }
        else
        {
                StrPrintF(message, "%d",bytes); 
                WinDrawChars(message, StrLen(message), 10*iCounter, 80);
        }
                
        err=SrmReceiveCheck (portRef,&bytes);
        if (err) StrPrintF(message, "%s", "Error");
        StrPrintF(message, "%d", bytes);
        WinDrawChars(message, StrLen(message), 10*iCounter, 110);
        iCounter++;

}
-- 
For information on using the Palm Developer Forums, or to unsubscribe, please 
see http://www.palmos.com/dev/support/forums/

Reply via email to