I am trying to communicate with a device that is connected through rs232 and
the palm serial port.  The problem that I? am having is that I
cannot get the Palm to send informtion to the device.  The code that I have
written works on the POSE but for some reason, I can't get the palm to
communicate with the device.  I can open the port correctly.  I just can't
seem to send anything through the opened port.

Here is my code:
/***********************************************************************
 *
 * FUNCTION:    meterOpenSerial
 *
 *
 ***********************************************************************/
 void meterOpenSerial(FormPtr frmP)
 {
  Err e;
  UInt port = 0;
  ULong baud = 9600;
  VoidPtr SerialBuffer = 0;
  SerSettingsType sstSetup;

  //Load the serial Library
  e = SysLibFind("Serial Library", &SerialRefNum);

  if(e)
  {
   FrmCustomAlert(1000, "Failed to Load Library!","","");
   return;
  }


  //Open the Serial Port
  e=SerOpen(SerialRefNum,port,baud);

  if(e)
  {
   FrmCustomAlert(1000, "Failed to Open Port!","","");
   return;
  }

    //Receive Parameters from Port
  SerGetSettings(SerialRefNum,&sstSetup);

  //Set Baud Rate and additional Settings
 sstSetup.baudRate = baud;
 sstSetup.flags=  serSettingsFlagBitsPerChar8 |
                          serSettingsFlagStopBitsM |
                         serSettingsFlagStopBits1 |
                         serSettingsFlagParityEvenM|
                         serSettingsFlagRTSAutoM|
                         serSettingsFlagCTSAutoM;

 sstSetup.ctsTimeout = (SysTicksPerSecond() / 2);

 e = SerSetSettings(SerialRefNum, &sstSetup);
 if (e == 0) Connected = 1;
  MemPtrNew (2048);
 e = SerSetReceiveBuffer(SerialRefNum,SerialBuffer,
 sizeof(SerialBuffer));
}

//Function that writes to the serial port

void meterWriteSerial(FormPtr frmP)
 {
   Err e;
   Char msg[] = "syst:type?\r\n";

   //Check connected
   if (Connected ==0) return;


     //Send the String
    SerSend(SerialRefNum,msg,StrLen(msg),&e);
    if(e)


   FrmCustomAlert(1000, "Error Sending Message!","","");
   return;
  }

  //Send a NewLine Character
  SerSend(SerialRefNum,(unsigned char *) "\n",1,&e);
  if (e == serErrBadParam) {
    }

  if(e)
  {
   FrmCustomAlert(1000, "Error Sending Message NewLine Character!","","");
   return;
  }

   }

Any Suggestions?





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

Reply via email to