×

Discussion Board

Results 1 to 14 of 14
  1. #1
    Registered User
    Join Date
    Apr 2007
    Posts
    15

    Infrared S60 EXtension (HELP ME :-[ )

    Hi I'm trying to program an extension to the S60_3rd_MR API to let me do infrared communication with an IrDA development board (MCP2150 if it matters). Using the C++ API I have managed to get the example code GlassTerm.cpp into such a shape that it allows me to send and receive characters to the board (that has a loopback connector Rx->TX and CTS/RTS are grounded).

    I have wrapped python around some of the methods and altered some others to try to get this thing running and I can call the module and write a character to the port which results in my development board realising there is another device connected.

    Using python (bluetooth console) I then try to read and always the receive an empty buffer, when the length of the buffer is queried or readoneormore is used then the interpreter crashes e.g. either of the lines below cause a crash.

    numberRead = commPort.QueryReceiveBuffer();
    commPort.ReadOneOrMore(readStat, localInputBuffer);

    If anyone has anything that can help me do this, or has any experience of what can and can't be done with Python and IrDA please help, my code is below:





    //PyS60serial

    #include <e32std.h>
    #include <EIKBTGPC.H>
    #include <avkon.hrh>
    #include <aknnavi.h>
    #include <aknnavide.h>
    #include <eikspane.h>
    #include <aknappui.h>
    #include <e32base.h>
    #include <e32test.h>
    #include <e32svr.h>
    #include <e32keys.h>
    #include <c32comm.h>
    #include <f32file.h>
    #include <Python.h>
    #include <symbian_python_ext_util.h>
    #include <e32cons.h>

    // exclude console
    // LOCAL_D CConsoleBase* console;

    _LIT(LDD_NAME,"ECOMM");

    #if defined (__WINS__)
    _LIT(PDD_NAME,"ECDRV");
    #else
    _LIT(PDD_NAME,"EUART1");
    #endif

    // short literals for print debug when running as a C file only
    _LIT(KMessage2,"%c\n");
    _LIT(KMessage14,"^%c");
    _LIT(KMessage15,"%c");
    _LIT(KColons,"::");
    _LIT(KMessage0,"Select S for RS232 Serial or R for InfraRed port : ");
    _LIT(KMessage1,"Select 0 for no handshaking, 1 for CTS/RTS and 2 for XON/XOFF :");
    _LIT(KMessage4,"Loading device drivers\n");
    _LIT(KMessage5,"Starting comms server\n");
    _LIT(KMessage6,"Connecting to comms server\n");
    _LIT(KMessage7,"Loading %S.CSY module\n");
    _LIT(KMessage8,"%S has %S available as %S::%u to %S::%u\n");
    _LIT(KMessage9,"Opened %S\n");
    _LIT(KMessage10,"Configuring Serial port for 115200 bps 8 bits no parity 1 stop\n");
    _LIT(KMessage11,"Powering up port\n");
    _LIT(KMessage12,"\nDisconnecting\n");
    _LIT(KMessage13,"\nWrite Failed %d\n");
    _LIT(KMessage16,"\nRead failed %d\n");
    _LIT(KMessage17,"Closed %S\n");
    _LIT(KMessage18,"Closing server connection\n");
    _LIT(KMessage19,"Comms server reports we have %u comms modules loaded\n");
    _LIT(KMessage20,"Using the lowest %S out of %S::%u to %S::%u\n");
    _LIT(KMessage21,"Complete\n");
    _LIT(KPanic,"StraySignal");
    _LIT(RS232,"BTCOMM");
    _LIT(IRCOMM,"IRCOMM");

    // Define an arbitrary buffer size and Hundred seconds in microseconds
    const TInt KBufSize (1);
    const TInt KOneHundredSecond (100000000);

    TInt r;
    TKeyCode handshakingMode; // No handshaking
    TBuf16 < 6 > csyName;
    TUint8 csyMode='R'; // Use IRdA instead of BT or USB
    const TUint8 mask=0xdf; // this mask 0xdf turns lower to upper case
    RCommServ server;
    RComm commPort;
    TCommCaps ourCapabilities;
    TCommConfig portSettings;
    TKeyCode key;
    TPtrC8 outputByte ((TUint8 *) & key, 1);
    TBuf8 < KBufSize > localInputBuffer;
    TRequestStatus readStat, keyStat;
    const TTimeIntervalMicroSeconds32 KTenthSecond(3000000);

    void printReceivedText(TDes8& localInputBuff,TInt numberRead)
    {
    TUint8 *nextByte = &localInputBuff[0];
    for (int i = 0; i < numberRead; i++, nextByte++)
    {
    }
    }

    //serial
    static PyObject* PyS60serial_IRsetup(PyObject* /*self*/, PyObject *args)
    {
    char* text_ = 0;
    TInt textlen = 0;
    if (!PyArg_ParseTuple(args, "u#", &text_, &textlen))
    {
    return 0;
    }
    TPtrC text((TUint16*)text_, textlen);

    TRAPD(err,
    CEikButtonGroupContainer::Current()->SetCommandL(EAknSoftkeyExit, text);
    CEikButtonGroupContainer::Current()->DrawDeferred();
    csyName.Copy(IRCOMM);
    User::LeaveIfError(server.Connect());
    r=server.LoadCommModule (csyName);
    User::LeaveIfError(r);
    TSerialInfo portInfo;
    r=server.GetPortInfo(csyName,portInfo);
    TBuf16 < KMaxPortName + 4 > portName;
    portName.Num(portInfo.iLowUnit);
    portName.Insert(0,KColons);
    portName.Insert(0,portInfo.iName);
    r=commPort.Open(server,portName,ECommExclusive);
    commPort.Caps(ourCapabilities);
    commPort.Config (portSettings);
    portSettings ().iRate = EBps9600;
    portSettings ().iParity = EParityNone;
    portSettings ().iDataBits = EData8;
    portSettings ().iStopBits = EStop1;
    portSettings ().iFifo = EFifoEnable;
    portSettings ().iHandshake = KConfigFailDSR; // for no handshaking
    portSettings ().iTerminator[0] = 10;
    portSettings ().iTerminatorCount = 1; // so that we terminate a read on each line feed arrives
    r = commPort.SetConfig (portSettings);
    User::LeaveIfError (r);
    // now turn on DTR and RTS, and set our buffer size
    commPort.SetSignals (KSignalDTR, 0);
    commPort.SetSignals (KSignalRTS, 0);
    TInt curlenth = commPort.ReceiveBufferLength ();
    commPort.SetReceiveBufferLength (256);
    curlenth = commPort.ReceiveBufferLength ();
    // now we can start using the port
    );
    return Py_BuildValue("s", "HEllo");
    //RETURN_ERROR_OR_PYNONE(err);
    }


    static PyObject* PyS60serial_initcon(PyObject* /*self*/, PyObject *args)
    {
    char* text_ = 0;
    TInt textlen = 0;
    if (!PyArg_ParseTuple(args, "u#", &text_, &textlen))
    {
    return 0;
    }
    TPtrC text((TUint16*)text_, textlen);

    // Load drivers
    TRAPD(err,
    // a null read or write powers up the port
    commPort.Read (readStat, localInputBuffer, 0);
    User::WaitForRequest(readStat);
    r = readStat.Int ();
    User::LeaveIfError (r);
    );

    RETURN_ERROR_OR_PYNONE(err);
    }



    static PyObject* PyS60serial_r2(PyObject* /*self*/, PyObject *args)
    {
    int i=0;
    char* text_ = 0;
    char* rtxt[6];
    char dtxt[6];
    TInt textlen = 0;
    if (!PyArg_ParseTuple(args, "u#", &text_, &textlen))
    {
    return 0;
    }
    TPtrC text((TUint16*)text_, textlen);
    rtxt[0]="p";
    rtxt[1]="p";
    rtxt[2]="p";
    rtxt[3]="p";
    rtxt[4]="p";

    dtxt[0]='n';
    dtxt[1]='n';
    dtxt[2]='n';
    dtxt[3]='n';
    dtxt[4]='n';
    dtxt[5]='n';
    // Load drivers
    //TRAPD(err,

    commPort.Read (readStat, KOneHundredSecond, localInputBuffer);
    for (;
    {
    User::WaitForRequest (readStat);
    dtxt[0]='y';
    // From keyboard

    if (readStat != KRequestPending)
    {
    dtxt[1]='y';
    if (readStat == KErrNone || readStat == KErrTimedOut)
    {
    // check descriptor and print any characters
    dtxt[2]='y';
    TInt numberRead = localInputBuffer.Length ();
    if (numberRead != 0)
    {printReceivedText(localInputBuffer,numberRead);
    dtxt[3]='y';}
    else
    // else check the input buffer and print any characters
    {
    dtxt[4]='y';
    numberRead = commPort.QueryReceiveBuffer();
    if (numberRead != 0)
    {
    dtxt[5]='y';
    commPort.ReadOneOrMore(readStat, localInputBuffer);
    User::WaitForRequest (readStat);
    if (readStat == KErrNone) printReceivedText(localInputBuffer,numberRead);
    }
    }
    }
    else // An error occured on reading
    commPort.Read (readStat, KOneHundredSecond, localInputBuffer);
    }

    // help !! a request we can't cater fo

    }
    //);

    return Py_BuildValue("s#", dtxt,6);
    }

    static PyObject* PyS60serial_close(PyObject* /*self*/, PyObject *args)
    {
    char* text_ = 0;
    TInt textlen = 0;
    if (!PyArg_ParseTuple(args, "u#", &text_, &textlen))
    {
    return 0;
    }
    TPtrC text((TUint16*)text_, textlen);
    TRAPD(err,
    commPort.Close ();
    server.Close ();
    );
    return Py_BuildValue("s", "close");
    }


    static PyObject* PyS60serial_write(PyObject* /*self*/, PyObject *args)
    {
    char* text_ = 0;
    TInt textlen = 0;
    if (!PyArg_ParseTuple(args, "u#", &text_, &textlen))
    {
    return 0;
    }
    TPtrC text((TUint16*)text_, textlen);
    TRAPD(err,
    key = (TKeyCode) 0x61;
    TRequestStatus stat;
    commPort.Write (stat, outputByte);
    User::WaitForRequest (stat);
    r = stat.Int ();
    if (r != KErrNone) // Write has failed for some reason
    );
    return Py_BuildValue("s", "write");
    }



    static PyObject* PyS60serial_cr(PyObject* /*self*/, PyObject *args)
    {
    char* text_ = 0;
    TInt textlen = 0;
    if (!PyArg_ParseTuple(args, "u#", &text_, &textlen))
    {
    return 0;
    }
    TPtrC text((TUint16*)text_, textlen);
    TRAPD(err,
    key = (TKeyCode)0x0d;
    TRequestStatus stat;
    commPort.Write (stat, outputByte);
    User::WaitForRequest (stat);
    r = stat.Int ();
    if (r != KErrNone) // Write has failed for some reason
    );
    return Py_BuildValue("s", "carriage return");
    }

    static const PyMethodDef PyS60serial_methods[] =
    {
    {"init", (PyCFunction)PyS60serial_IRsetup, METH_VARARGS},
    {"con", (PyCFunction)PyS60serial_initcon, METH_VARARGS},
    {"r2", (PyCFunction)PyS60serial_r2, METH_VARARGS},
    {"close", (PyCFunction)PyS60serial_close, METH_VARARGS},
    {"write", (PyCFunction)PyS60serial_write, METH_VARARGS},
    {"cr", (PyCFunction)PyS60serial_cr, METH_VARARGS},
    {0, 0} /* sentinel */
    };




    DL_EXPORT(void) init_PyS60serial()
    {
    PyObject* module = Py_InitModule("_PyS60serial",
    (PyMethodDef*) PyS60serial_methods);
    }

    #ifndef EKA2
    GLDEF_C TInt E32Dll(TDllReason)
    {
    return KErrNone;
    }
    #endif

  2. #2
    Regular Contributor
    Join Date
    Jan 2007
    Posts
    80

    Re: Infrared S60 EXtension (HELP ME :-[ )

    Its great to hear that someone is actually working in this extension that so many people want, but for the C++ side I think you might have a easier time getting help from the C++ section of the forum, not the python since most people are probable oblivious to coding in C++ on the phone.

    Good luck

  3. #3
    Registered User
    Join Date
    Feb 2008
    Posts
    9

    Re: Infrared S60 EXtension (HELP ME :-[ )

    It's a 5-6 months old message and I hope to get an answer, I'm trying to let a phone comunicate with a circuit too! Any luck porting that module to python? Do you have some hints or material to share with us about your project?

  4. #4
    Registered User
    Join Date
    Apr 2007
    Posts
    15

    Re: Infrared S60 EXtension (HELP ME :-[ )

    Hi,

    In the end I gave up on using IrDA, I spoke to some poeple at symbian/nokia and they told me to give up since nokia weren't supporting this and are focussing on bluetooth. It seems to be the case since you can never get an answer when doing infrared.

    Instead I had to pay £60 for a bluetooth to rs232 adapter. Since you can use the sockets API and there are plenty of people out there doing the same it is much easier. It took about an hour to work out how to work the thing and since then I have had no problems

    Best of Luck,
    Alistair

  5. #5
    Registered User
    Join Date
    Apr 2007
    Posts
    15

    Re: Infrared S60 EXtension (HELP ME :-[ )

    BTW what is the project you are working on

  6. #6
    Registered User
    Join Date
    Feb 2008
    Posts
    9

    Re: Infrared S60 EXtension (HELP ME :-[ )

    Oh i'm luky, someone is alive ;D!
    My progect is something very difficult to explain, but however is to apply a nokia symbian phone on a little helicopter and then let the phone control the helicopter by using a connection with a gps over bt.
    My aim is to "scan" with a 3mpx (n73) camera a little area and make some cool maps. The problem is that I don't know how to make a connection between phone and helicopter, since irda is not working, bluetooth seems to be a very difficult option to work on I've got no idea of what to do. A friend of mine told me to use the audio output of the phone and put it in a ciruit with many transistors to let phone control engines.
    Do you like this project?
    Luca

  7. #7
    Nokia Developer Moderator
    Join Date
    May 2007
    Location
    21.46 N 72.11 E
    Posts
    3,800

    Re: Infrared S60 EXtension (HELP ME :-[ )

    Quote Originally Posted by talentdream View Post
    Oh i'm luky, someone is alive ;D!
    My progect is something very difficult to explain, but however is to apply a nokia symbian phone on a little helicopter and then let the phone control the helicopter by using a connection with a gps over bt.
    My aim is to "scan" with a 3mpx (n73) camera a little area and make some cool maps. The problem is that I don't know how to make a connection between phone and helicopter, since irda is not working, bluetooth seems to be a very difficult option to work on I've got no idea of what to do. A friend of mine told me to use the audio output of the phone and put it in a ciruit with many transistors to let phone control engines.
    Do you like this project?
    Luca
    You can use the N95 built accelerometer too
    And Bluetooth will be the best way to communicate with the helicopter.

    And yes the project sounds good.

    Best Regards
    Croozeus
    Pankaj Nathani
    www.croozeus.com

  8. #8
    Nokia Developer Champion
    Join Date
    Feb 2008
    Location
    Ahmedabad, Gujarat, India
    Posts
    3,852

    Re: Infrared S60 EXtension (HELP ME :-[ )

    Quote Originally Posted by talentdream View Post
    Oh i'm luky, someone is alive ;D!
    My progect is something very difficult to explain, but however is to apply a nokia symbian phone on a little helicopter and then let the phone control the helicopter by using a connection with a gps over bt.
    My aim is to "scan" with a 3mpx (n73) camera a little area and make some cool maps. The problem is that I don't know how to make a connection between phone and helicopter, since irda is not working, bluetooth seems to be a very difficult option to work on I've got no idea of what to do. A friend of mine told me to use the audio output of the phone and put it in a ciruit with many transistors to let phone control engines.
    Do you like this project?
    Luca
    hi
    your project sounds extreme nice. the best option is to use a bluetooth module. you can get the reference from forum itself.
    moreover you need some knowledge of interfacing of bluetooth hardware.
    accelerometer is again a very nice option and bit easy.
    check out here.http://blogs.forum.nokia.com/blog/an...ow-open-source

  9. #9
    Registered User
    Join Date
    Feb 2008
    Posts
    9

    Re: Infrared S60 EXtension (HELP ME :-[ )

    Thanks for helping!
    What you told me about n95 is unsuitable for this project, because the phone will stay on the plane (some kind of semi-uav plane)!
    I'll probabily use bluetooth, even if I'd like to spend less than 100$ for the Bluetooth-RS232 I will need , or maybe I'll use the audio cable exit from the phone (something is telling me i'll lose my phone doing that but I love to try!)
    I'll use pyastra for simple assembly code if someone is interested...

  10. #10
    Registered User
    Join Date
    May 2008
    Posts
    5

    Re: Infrared S60 EXtension (HELP ME :-[ )

    any news on either the sound approach or bt<->rs232 or native irda?

  11. #11
    Registered User
    Join Date
    Feb 2008
    Posts
    9

    Re: Infrared S60 EXtension (HELP ME :-[ )

    None, actually the project has been stopped for a few time, but now I'm going to work on it again. I think I'm going to use PIC's MicroBlue microcontroller (and then interact with the phone).
    Any idea on how to interact with a simple rc bluetooth controller? Could you provide simple() examples, please?
    Thank you very much!
    Luke

  12. #12
    Nokia Developer Champion
    Join Date
    Feb 2008
    Location
    Ahmedabad, Gujarat, India
    Posts
    3,852

    Re: Infrared S60 EXtension (HELP ME :-[ )

    Quote Originally Posted by talentdream View Post
    None, actually the project has been stopped for a few time, but now I'm going to work on it again. I think I'm going to use PIC's MicroBlue microcontroller (and then interact with the phone).
    Any idea on how to interact with a simple rc bluetooth controller? Could you provide simple() examples, please?
    Thank you very much!
    Luke
    hi TalentDream

    i once upon a time used to work on microcontrollers and python. Have a look at this link it can help you a bit.

    Enjoy Pythoning
    Gaba88

  13. #13
    Registered User
    Join Date
    Feb 2008
    Posts
    9

    Re: Infrared S60 EXtension (HELP ME :-[ )

    Ok thanks, it seems a very reasonable option for bluetooth comunication and ease of use. Even made in Italy =D!

    Question for moderators: Could you change post name in "Pys60 and bluetooth microcontrollers"?

  14. #14
    Nokia Developer Champion
    Join Date
    Feb 2008
    Location
    Ahmedabad, Gujarat, India
    Posts
    3,852

    Re: Infrared S60 EXtension (HELP ME :-[ )

    Quote Originally Posted by talentdream View Post
    Ok thanks, it seems a very reasonable option for bluetooth comunication and ease of use. Even made in Italy =D!

    Question for moderators: Could you change post name in "Pys60 and bluetooth microcontrollers"?
    hi talentdream
    yes thats a very nice option, another most important thing is that in the board everything is open source even the hardware itself. So if one knows a bit of electronics can do a lot with it.

    Moreover though i am not a moderator if you want to discuss problems related to bluetooth and microcontrollers why dont you start a separate thread.

    Enjoy Pythoning
    Gaba88

Similar Threads

  1. ANN: Accredited S60 Developer Program
    By Nokia Ron in forum Feedback - Nokia Developer Services & Infrastructure
    Replies: 3
    Last Post: 2012-03-26, 22:33
  2. Replies: 0
    Last Post: 2007-03-28, 08:59
  3. 6600 Infrared Connection Problem with XP
    By rizzir in forum General Development Questions
    Replies: 0
    Last Post: 2004-08-12, 10:36
  4. Almost all tools (S60 MIDP SDK B0.1, Nokia S60 SDK Symbian OS v0.3) Crashes
    By alexandershalamov in forum Symbian Tools & SDKs
    Replies: 1
    Last Post: 2002-07-03, 13:44

Posting Permissions

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