×

Discussion Board

Results 1 to 2 of 2
  1. #1
    Registered User
    Join Date
    Mar 2003
    Posts
    9

    problem with 9210 machine serial rs232 and IRCOMM connectivity

    I am trying to connect a device that sends data to 9210 via rs232 or IR. my code works fine in WINS, I also think that I have solved thanks to you the PLP problem, still I don't receive the data in 9210 ARMI.
    Am i supposed to config the IRCOMM ? I tried but got "not supported"
    In IRCOMM I also didn't succeed to get to get IR capabilities, also getting "not supported",
    Here is the code, please have a look and help me, thanks Daniel


    #define IR 1 // 1 for ircomm 0 for rs232
    _LIT(LDD_NAME,"ECOMM"
    _LIT(KPanic,"StraySignal"
    #if defined (__WINS__)
    _LIT(PDD_NAME,"ECDRV"
    #else
    _LIT(PDD_NAME,"EUART1"
    #endif


    #if IR
    _LIT(IrCOMM,"IrCOMM"
    csyName.Copy(IrCOMM);
    #else
    _LIT(RS232,"ECUART"
    csyName.Copy(RS232);
    #endif


    // load physical and logical devices
    // in WINS it will search in C:\EPOC32\Wins\C\System\libs
    TInt r = User::LoadPhysicalDevice (PDD_NAME);
    if (r != KErrNone && r != KErrAlreadyExists)
    User::Leave (r);
    r = User::LoadLogicalDevice (LDD_NAME);
    if (r != KErrNone && r != KErrAlreadyExists)
    User::Leave (r);

    r = StartC32 ();
    if (r != KErrNone && r != KErrAlreadyExists)
    User::Leave (r);



    // connect to server
    User::LeaveIfError (iCommServ.Connect ());



    // Load the CSY module
    // EPOC/32 will automatically search \System\Libs
    // on all drives starting from C:
    // in WINS it will search in C:\EPOC32\Wins\C\System\libs
    r = iCommServ.LoadCommModule (csyName);
    User::LeaveIfError (r);



    //Select the module to use.
    TBuf<10> moduleName;

    #if IR
    TBuf16 <9> comm0 (_L("IrCOMM::0&quot);
    _LIT(KInfraRedModuleName, "IrCOMM"
    moduleName.Copy(KInfraRedModuleName);
    #else
    TBuf16 <7> comm0 (_L("COMM::0&quot);
    _LIT(KCableModuleName, "COMM"
    moduleName.Copy(KCableModuleName);
    #endif
    TSerialInfo portInfo;
    r = iCommServ.GetPortInfo(moduleName, portInfo);
    if (r != KErrNone && r != KErrAlreadyExists)
    User::Leave (r);
    #if IR
    if((moduleName.CompareF(KInfraRedModuleName)) == 0)
    #else
    if((moduleName.CompareF(KCableModuleName)) == 0)
    #endif
    {
    TBps remoteLinkBaud;
    TPortName port;
    RRemoteLink link;
    TInt ret = link.Open();
    if (ret == KErrNone)
    {
    ret = link.Config(&remoteLinkBaud, &port);
    if (ret == KErrNone)
    link.Disable();
    link.Close();
    }
    }

    // if we know our machine architecture we can just go ahead and open (say) COMM::0
    r = iComm.Open (iCommServ, comm0 , ECommExclusive);
    User::LeaveIfError (r);



    // Now we can configure our serial port
    // we want to run it at 38400 bps 8 bits no parity (why not?)
    // so maybe we ought to get of its capabilities and check it can
    // do what we want before going ahead
    TCommCaps ourCapabilities;
    iComm.Caps (ourCapabilities);
    #if IR // here i get not supported
    if ((ourCapabilities ().iSIR & KCapsSIR115kbps) == 0)
    User::Leave (KErrNotSupported);
    portSettings ().iSIREnable = ESIREnable;
    portSettings ().iSIRSettings = KCapsSIR115kbps;
    #else
    if (((ourCapabilities ().iRate & KCapsBps38400) == 0) |
    ((ourCapabilities ().iDataBits & KCapsData8) == 0) |
    ((ourCapabilities ().iStopBits & KCapsStop1) == 0) |
    ((ourCapabilities ().iParity & KCapsParityNone) == 0))

    User::Leave (KErrNotSupported);
    TCommConfig portSettings;
    iComm.Config (portSettings);
    portSettings ().iRate = EBps38400;
    portSettings ().iParity = EParityNone;
    portSettings ().iDataBits = EData8;
    portSettings ().iStopBits = EStop1;

    #endif



    // as well as the physical characteristics, we need to set various logical ones
    // to do with handshaking, behaviour of reads and writes and so so
    portSettings ().iFifo = EFifoEnable;



    // handshaking - one of these
    // portSettings ().iHandshake = (KConfigObeyXoff | KConfigSendXoff); // for xon/xoff
    //portSettings ().iHandshake = (KConfigObeyCTS | KConfigFreeRTS); // for cts/rts
    portSettings ().iHandshake = KConfigFailDSR; // for no handshaking


    // SetConfig to store values
    r = iComm.SetConfig (portSettings);
    User::LeaveIfError (r);



    // now turn on DTR and RTS, and set our buffer size
    // if dtr RTS needed

    iComm.SetSignals (KSignalDTR, 0);
    iComm.SetSignals (KSignalRTS, 0);

    TInt curlenth = iComm.ReceiveBufferLength ();
    iComm.SetReceiveBufferLength (4096);
    curlenth = iComm.ReceiveBufferLength ();
    iTimeOut = KTenthSecond;
    CActiveScheduler::Add(this);
    }

    ReadComm::~ReadComm() // the destructor
    {
    ReadComm::Cancel();
    iComm.Close();
    iCommServ.Close();
    //- And in the end remember to enable PLP.
    RRemoteLink link; //PLP server
    TInt ret = link.Open();
    if (ret == KErrNone)
    {
    const TBps plpSpeed = EBps115200;
    _LIT(KSerialPortName,"COMM::0"
    _LIT(KSerialPortFileName,"ECUART"
    ret = link.Enable(/*KPlpSpeed*/plpSpeed, KSerialPortName, KSerialPortFileName);
    link.Close();
    }
    }

  2. #2
    Registered User
    Join Date
    Mar 2003
    Posts
    9

    RE: problem with 9210 machine serial rs232 and IRCOMM connectivity

    sorry guys, this code works. it was a hardware problem...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×