×

Discussion Board

Page 1 of 2 12 LastLast
Results 1 to 15 of 21
  1. #1
    Regular Contributor
    Join Date
    Jan 2009
    Posts
    264

    Problem in Writing Data on Serial USB Ports in S60_3rd_FP1

    Hi all
    I am trying to read and Write data on Serial USB ports in S60_3rd_FP1. For this i have created 2 Active Object classes. One for reading and one for writing. I have already done this before in S60_2nd_FP3 and application is running successfully .

    But in 3rd edition when i try to write data on ports it does not happen . the write() function completes successfully and RunL() is called but data is not written. I have created different methods for intialize, configuring, and writing data on ports.
    i am calling them in following sequence
    1 initializePorts(); //
    2 configurePortL();
    3 WriteData();
    4 CActiveSchduler::Start(); // will be stopped in RunL

    1 initializePorts()
    Code:
    void CWriteToPorts::initializePorts()
    	{
    	#define PDD_NAME _L("EUART1")
    	#define LDD_NAME _L("ECOMM")
    	User::LoadPhysicalDevice (PDD_NAME); // step 1 
    	User::LoadLogicalDevice (LDD_NAME); // step 2 
    	StartC32 (); //step 3
    	server.Connect (); // step 4
    	server.LoadCommModule (_L ("ECUART")); // step 5
    	commPort.Open (server, _L ("COMM::1"), ECommExclusive); 
    	}
    2 configurePortL()
    Code:
    void CWriteToPorts::configurePortL()
    	{TInt r;
    	 TCommCaps portCaps;
    	 commPort.Caps( portCaps );
    	 if (((portCaps().iRate & KCapsBps9600) == 0) |
    	 ((portCaps().iDataBits & KCapsData8) == 0) |
    	 ((portCaps().iStopBits & KCapsStop1) == 0) |
    	 ((portCaps().iParity & KCapsParityNone) == 0))
    	      {
    	       User::Leave( KErrNotSupported );
    	       }
    	 TCommConfig portCfg;
    	 commPort.Config( portCfg );
    	 portCfg().iRate     =   EBps9600;
    	 portCfg().iParity   =   EParityNone;
    	 portCfg().iDataBits =   EData8;
    	portCfg().iStopBits =   EStop1;
    	portCfg().iHandshake =  0;
    	User::LeaveIfError( commPort.SetConfig( portCfg ) );
    	 }
    3 writeData()
    Code:
    void CWriteToPorts::writeData()
    	{
    	console->Printf(_L("Entered Writing \n"));
    	_LIT8(cmd,"Hello data ....");
    	commPort.Write(iStatus, cmd);
    	SetActive();
    	}
    runL method called when request completes
    Code:
    void CWriteToPorts::RunL()
    	{
    	console->Printf(_L("Enter in RunL .. \n"));
    	User::After(2000000);
    	CActiveScheduler::Stop();
    	}
    i am calling these methods and then i start CActiveScheduler
    plz help me and guide me where i am wrong or suggest me some way
    Regards
    Gaurav Gupta
    Thanks & Regards
    Gaurav Gupta

  2. #2
    Nokia Developer Moderator
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,168

    Re: Problem in Writing Data on Serial USB Ports in S60_3rd_FP1

    any chance that you would have checked the error code from the iStatus variable in your RunL ?

    Also do check all error values from all function calls, they might give you nice information on what is going wrong.

  3. #3
    Regular Contributor
    Join Date
    Jan 2009
    Posts
    264

    Re: Problem in Writing Data on Serial USB Ports in S60_3rd_FP1

    Sir i have checked the iStatus before writing to ports and in RunL() method. I am getting value of iStatus = 0 . Does it means there is no error ...?
    and please take a look of configurePortL() that i have posted .
    These are setting that i have done while configuring ports.

    TCommConfig portCfg;
    commPort.Config( portCfg );
    portCfg().iRate = EBps9600;
    portCfg().iParity = EParityNone;
    portCfg().iDataBits = EData8;
    portCfg().iStopBits = EStop1;
    portCfg().iHandshake = 0;

    Is something missing there sir ... ?
    Regards
    Gaurav Gupta

  4. #4
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,751

    Re: Problem in Writing Data on Serial USB Ports in S60_3rd_FP1

    Then consider applying the second paragraph of Jukka's post. Almost every method you are calling has a return value. Any of them can fail.

  5. #5
    Regular Contributor
    Join Date
    Jan 2009
    Posts
    264

    Re: Problem in Writing Data on Serial USB Ports in S60_3rd_FP1

    hi wizard sir
    Sir i have acted on jukka sir advice and i have tested each and every function there is no leave or any error sir i have done logging in my project and logs are prepared as expected ..
    But then also data is not written on ports...
    please advice me what could be the problem ...
    Regards
    Gaurav Gupta

  6. #6
    Regular Contributor
    Join Date
    Jan 2009
    Posts
    264

    Re: Problem in Writing Data on Serial USB Ports in S60_3rd_FP1

    Quote Originally Posted by wizard_hu_ View Post
    Then consider applying the second paragraph of Jukka's post. Almost every method you are calling has a return value. Any of them can fail.
    wizard sir

    i have cross checked my program but was not able find any error but the result is same. Data is not written on ports. Can anyone plz tell me what is the problem in code. ?
    Thanks & Regards
    Gaurav Gupta

  7. #7
    Regular Contributor
    Join Date
    Jan 2009
    Posts
    264

    Re: Problem in Writing Data on Serial USB Ports in S60_3rd_FP1

    Wizard Sir
    i am not able to find out if i am able to read/write data on ports in 2nd edition why is it not working in S60_3rd_FP1 ...Sir i am using same technique that i used in 2nd edition and application is working fine in S60_2nd_FP3 edition .
    PLZ SUGGEST ME SOMETHING...

    Regards
    Gaurav Gupta
    Thanks & Regards
    Gaurav Gupta

  8. #8
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,751

    Re: Problem in Writing Data on Serial USB Ports in S60_3rd_FP1

    How does your current code look like?

  9. #9
    Regular Contributor
    Join Date
    Jan 2009
    Posts
    264

    Re: Problem in Writing Data on Serial USB Ports in S60_3rd_FP1

    HI WIZARD SIR THIS IS THE CODE THAT I AM USING. My class is Active Object class , i am developing application for S60_3rd_FP1. These functions are called in following sequence.

    intializeportsL()
    configurePortL()
    writeData()
    I am calling Active Scheduler start() After calling WriteData and stoping it in RunL .

    CODE TO INITIALIZE PORTS
    Code:
    void CWriteToPorts::initializePortsL()
    	{
    	#define PDD_NAME _L("EUART1")
    	#define LDD_NAME _L("ECOMM")
    	User::LoadPhysicalDevice (PDD_NAME); // step 1 
    	User::LoadLogicalDevice (LDD_NAME); // step 2 
    	TInt ret =StartC32 (); // step 3
    	 if ( ret != KErrNone && ret != KErrAlreadyExists )
    				        {
    				        User::Leave ( ret );
    				        }
    	User::LeaveIfError(server.Connect ()); // step 4
    	User::LeaveIfError(server.LoadCommModule (_L ("ECUART"))); // step 5
    	User::LeaveIfError(commPort.Open (server, _L ("COMM::1"), ECommExclusive)); // step 6
    	
    	}
    CODE TO CONFIGURE PORTS
    Code:
    void CWriteToPorts::configurePortL()
    	{
    	 TCommCaps portCaps;
    	 User::After(1000000);
    		 commPort.Caps( portCaps );
    		 if (((portCaps().iRate & KCapsBps9600) == 0) |
    		        ((portCaps().iDataBits & KCapsData8) == 0) |
    		        ((portCaps().iStopBits & KCapsStop1) == 0) |
    		        ((portCaps().iParity & KCapsParityNone) == 0))
    		       {
    		       globalFile.Write(_L8("Not Supported...."));
    		       User::Leave( KErrNotSupported );
    		       }
     
    		 TCommConfig portCfg;
    		 commPort.Config( portCfg );
    		     portCfg().iRate     =   EBps9600;
    		     portCfg().iParity   =   EParityNone;
    		     portCfg().iDataBits =   EData8;
    		     portCfg().iStopBits =   EStop1;
    		     portCfg().iHandshake =  0;
    		     portCfg().iTerminator[0] = 10;//
    		     portCfg().iTerminatorCount = 1;
    		     globalFile.Write(_L8(" setConfig \n"));
    		     User::LeaveIfError( commPort.SetConfig( portCfg ) );
    		     globalFile.Write(_L8(" setConfig success \n"));//write to log file	
    		     commPort.SetSignals (KSignalDTR, 1);
    		     commPort.SetSignals (KSignalRTS, 1);
    		     commPort.SetReceiveBufferLength (4096);
    		     }
    CODE TO WRITE TO PORTS

    Code:
    void CWriteToPorts::writeData()
    	{
    	_LIT8(cmd,"Hello data from ....");
    	commPort.Write(wStatus, cmd);
    	SetActive();
    	console->Printf(_L("written \n"));
    	User::After(1000000);
    	console->Printf(_L("Data written to port... \n"));
    	User::After(1000000);
    	}
    RUNL
    Code:
    void CWriteToPorts::RunL()
    	{
    	console->Printf(_L("Enter in RunL .. \n"));
    	CActiveScheduler::Stop();
    	}
    Regards
    Gaurav Gupta

  10. #10
    Regular Contributor
    Join Date
    Jan 2009
    Posts
    264

    Re: Problem in Writing Data on Serial USB Ports in S60_3rd_FP1

    Quote Originally Posted by wizard_hu_ View Post
    How does your current code look like?
    hi wizard sir
    i have pasted my code and i am waiting for your reply.. please take a look and tell me where i am wrong why i am not able to write to Serial USB ports...

    Thanks & Regards
    Gaurav Gupta
    Thanks & Regards
    Gaurav Gupta

  11. #11
    Nokia Developer Moderator
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,168

    Re: Problem in Writing Data on Serial USB Ports in S60_3rd_FP1

    BTW, have you tried the wiki code: http://wiki.forum.nokia.com/index.ph...dition_devices

  12. #12
    Regular Contributor
    Join Date
    Jan 2009
    Posts
    264

    Re: Problem in Writing Data on Serial USB Ports in S60_3rd_FP1

    Quote Originally Posted by symbianyucca View Post
    yes sir i have tried it. there is no issue with the code the code executes succesfully but data is not written on the ports..
    As you said i had checked all the functions and the istatus value before writing and in RunL()
    Sir i am getting iStatus value = 0 at both value..
    Kindly suggest something.. i have pasted my code please check if there is any flaw ..
    Regards
    Gaurav Gupta
    Thanks & Regards
    Gaurav Gupta

  13. #13
    Nokia Developer Moderator
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,168

    Re: Problem in Writing Data on Serial USB Ports in S60_3rd_FP1

    the wiki example is said to work, thu if you are not getting errors, then maybe you should check that your receivig code is also made correctly..

  14. #14
    Regular Contributor
    Join Date
    Jan 2009
    Posts
    264

    Re: Problem in Writing Data on Serial USB Ports in S60_3rd_FP1

    Quote Originally Posted by symbianyucca View Post
    the wiki example is said to work, thu if you are not getting errors, then maybe you should check that your receivig code is also made correctly..
    Actually i am using a software that listens to the serial USB ports .It is a tested software and when i send data on ports using my S60_2nd_FP3 application. It reads data and displays it on the screen. But in case of S60_3rd_FP1 nothing is read..from the ports...
    Sir have you read my code that i have pasted in the previous posts... Did you find any problem with it...

    Regards
    Gaurav Gupta

  15. #15
    Regular Contributor
    Join Date
    Jan 2009
    Posts
    264

    Re: Problem in Writing Data on Serial USB Ports in S60_3rd_FP1

    hi

    i have worked same like wiki example. The only changes i have made is
    1 instead of Communication Module :ECACM i have used ECUART
    2 instead of Port Name ACM::1 i have used COMM::1

    i have made these changes because if i use any of these my application leaves with code -46 .

    According the SDK it is correct and one more thing ECACM is used on Emulator and i am testing it on N95 device so for Device the communication It is ECUART which is again correct..

    i donot know why this -46 leave code comes ..

    please help ..
    Thanks & Regards
    Gaurav Gupta

Similar Threads

  1. Problem initiating OBEX over USB!
    By oberg in forum OMA DM/DS/CP
    Replies: 8
    Last Post: 2008-11-09, 17:31
  2. Replies: 2
    Last Post: 2008-08-28, 10:02
  3. How to connect Nokia 3500c to PC via USB data cable programatically
    By SGupta in forum Wired and Wireless interfaces (Closed)
    Replies: 0
    Last Post: 2007-11-16, 09:35
  4. problem in writing data into gallery
    By Basu in forum Mobile Java Networking & Messaging & Security
    Replies: 8
    Last Post: 2007-05-30, 22:19
  5. GPRS connection problems on 6600..
    By suckho in forum Symbian Networking & Messaging (Closed)
    Replies: 10
    Last Post: 2005-12-02, 14:00

Posting Permissions

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