/* Project: Socrates */
Learning Embedded Systems With Windows CE
 
Blog Entries    Windows Mobile    Socrates    
Login
Register



Home

Blog Archives

Socrates?

Chapters

Best Practices

Discuss

Open Editing

Pocket PC

Downloads

Favorite Links

Biography

About Web Site


Home

Problems With .NET CF SP1 Serial Classes and Socrates 1

Posted by on Friday, March 09, 2007 (PST)

In this entry I discuss a workaround for using the .NET CF SP1 serial classes with CE 6.0, and recent work on a new robot dubbed Socrates 1.

It has been awhile since I have posted anything to the blog, and I have a couple of items I would like to bring up. 

I have been working on a new robot, "Socrates 1", and I will be posting pictures sometime this month.  It is still a work-in-progress, but I expect that it will be operational in about two weeks.  Then the fun will begin, as I endeavor to create *reusable* navigation algorithms using principles of both Probabilistic and Soft (hybrid genetic algorithms and simulated neural net) Computing.  I will be using the Microsoft Robotic Studio to host the algorithms running on a remote PC sending commands to the robot over a WiFi connection. 

I have a lot to learn in many technology domains, but I have done the research and I am ready to begin.  My hope is to create a working Telepresence robot and a few research papers along the way documenting my results.

Another matter…

Something I noticed during early testing of Socrates 1 with the very cool Serializer.NET board (provides low level control functions), is that I was having a problem communicating with the RS-232 port on my eBox 2300  when using .NET CF 2.0 SP1 and CE 6.0.  Eventually I was able to get things working, but I had to make a few minor changes to the reference RS-232 driver provided with CE 6.0.  The changes are as follows:

The .NET CF framework attempts to set the driver queue size, which is not supported in the current version of the driver.  This causes SetLastError to be called which results in an exception in the .NET CF code.  The source code excerpted below displays the required modification in $(_WINCEROOT)\public\common\oak\drivers\serial\com_mdd2\mdd.c at about line 2878.  The comments prefixed with “NOTE:” belong to the original developer, and are not mine .

    case IOCTL_SERIAL_SET_QUEUE_SIZE :
        // BEGIN .NET CF WORKAROUND: JYW, Trying to accomodate .NETCF.
        // SetLastError(ERROR_NOT_SUPPORTED);
        // RetVal = FALSE;
        RetVal = TRUE;
        // END .NET CF WORKAROUND: JYW

        // NOTE: Normally we would do something with the passed in parameter.
        // But we don't think the user has a better idea of queue sizes
        // compared to our infinite knowledge.

The other change occurs at about line 611 in the same file, and is required because the .NET CF framework does not properly initialize the XON/XOFF limits.  My guess is that since XON/XOFF is not supported in the .NET CF serial classes, these fields were just left uninitialized in the DCB structure.  The modified source code is depicted below.

ApplyDCB (PHW_INDEP_INFO pSerialHead, DCB *pDCB, BOOL fOpen)
{
    PHWOBJ          pHWObj      = pSerialHead->pHWObj;

// BEGIN .NET CF WORKAROUND: JYW
//    if (!(pDCB->XoffLim< pSerialHead->RxBufferInfo.Length &&
//            pDCB->XonLim< pSerialHead->RxBufferInfo.Length - pDCB->XoffLim )) {
//        return FALSE;
//    }
// END .NET CF WORKAROUND: JYW

After these two changes were made, I am happy to report that the .NET CF 2.0 SP1 serial classes worked quite well with my Serializer.NET board. 

I have a lot more to say about the journey I have taken in assembling Socrates 1, particularly on my selection of sensors and controller from RoboticsConnection.  Unfortunately, I need to get ready for a business trip.

Until next time,

James (Jim) Y. Wilson


Comments:

How to rebuild code after making suggested changes
By snadden on Tuesday, May 08, 2007 (PST)

Hi,

I also have an eBox-2300 and I need to use the serial ports to control other equipment. I think I have the same problem that you described where an exception is thrown when I open the serial ports, and I would like to try to use your solution. I have noticed that if I simply catch the exception and then ignore it then everything seems to work, but I don't like that solution!

I have modified the source code in mdd.c to try to workaround this, as you suggested. My problem is forcing Visual Studio to recompile this file when it rebuilds my OS image. I have added a deliberate syntax error in the file to try to verify that it is included in the build of my image by generating a compiler error. However, if I rebuild my OS image, or perform a clean build, or rebuild the BSP then I get no build errors and so I don't think this file is included in my project.

Am I missing something simple?

Mike

RE: How to rebuild code after making suggested changes
By jywilson on Tuesday, June 26, 2007 (PST)

Mike,

I realize I am way late in responding, too late to be of assistance I suspect.  Just in case, however, let me ask one question.

Have you tried using the Build | Advanced Build Commands | Build and Sysgen option?  This command may be used to build code under the Public tree.  None of the other build commands will cause the Public tree to be built unless it is a fresh install of PB and the build system detects that the libraries are missing (not the case here). 

Jim

WinCe 5.0 image fo PC
By appuvivan on Tuesday, July 03, 2007 (PST)
Hello ,
 
       I have a doubt regarding the WinCe 5.0 image fo PC ,
 
Iam trying to build a WinCe 5.0 Image for a intel pentium 4 processor based Target PC ,
 What i find is that after executing the boot floppy i give the command loadcepc to take the image from the hard disc, but none of the storage device is detected by the boot floppy,
What could be the problem ?
IF i put a tiny image on floppy itself then execute loadcepc then the screen shown a memory location and it is not able to come out of it continue booting of WinCe on the PC ,
 
 
I wanted to know it there are any setting change required for booting a PC with WinCe ?
 
 
Thank you
 
Regards
Mani

Serial Port Read Problem
By jywilson on Wednesday, August 01, 2007 (PST)

Submitted on behalf of Amir Shekari:

==========================================

 

Dear Sir

 

First I could not open serial port. I enter below change in $(_WINCEROOT)\public\common\oak\drivers\serial\com_mdd2\mdd.c .

 

http://www.learningce.com/816.aspx

 

 

 

now I can open and send data. But when I want to .readexisting() "An unexpected error has occurred"

 

I install dotnetframework 2.0 SP1 and SP2  but problem exist.

 

 

 

Best regards,

 

Amir Shekari

RE: Serial Port Read Problem
By jywilson on Wednesday, August 01, 2007 (PST)

“now I can open and send data. But when I want to .readexisting() "An unexpected error has occurred"

 

Can you provide a stack trace when the exception occurs?  Also, do you get the same error when reading data using the Read() method?

Jim Wilson

 





New Articles
  • FIRST Tech Challenge
    A brief account of my experiences volunteering as a judge for the FIRST Tech Challenge held at California State University at Northridge.

  • Greetings Robot Fans!
    Monocular SLAM, DARPA Urban Challenge, RoboticsConnection.com, and the ImagineCup 2008.

  • Socrates I Lives!
    The first phase of Socrates I (research robot) construction is complete. It's not pretty, but it has all the necessary features to explore high level navigation algorithms using the Microsoft Robotic Studio (http://msdn.microsoft.com/robotics/).

  •  

    New Posts

  • Windows CE 5.0 Vs 6.0
    Posted by vsanghi@e-consystems.com on Tuesday, June 12, 2007 (PST)

  • Access to Data Rates Beyond 115.2 Kbps From .NET CF
    Posted by jadams on Thursday, November 16, 2006 (PST)

  • Getting Started With BSP Migration
    Posted by jywilson on Tuesday, October 24, 2006 (PST)

  •  

    New Downloads

  • AutoLaunch V1.0.zip
    This file contains the AutoLaunch CE 6.0 subproject.

  • PhidgetsDrivers-CE60 Project Files.zip
    The CE 6.0 project files and latest release from CodePlex of the Phidgets drivers.

  • PhidgetDrivers-PB Project Files.zip
    This file contains the Platform Builder 5.0 project files to include the Phidgets drivers in your OS image.


  •  

    Home   |   Blog Archives   |   Socrates?   |   Chapters   |   Best Practices   |   Discuss   |   Open Editing   |   Pocket PC   |   Downloads   |   Favorite Links   |   Biography   |   About Web Site