Session expiration Your session is going to expireClick here to extend


Small project <800

Posted on

1/21/13 1:31 PM



This project has expired

Why don't you register anyway? We are sure that you will find many similar projects out of the thousands waiting for you!

Post similar project now


i urgently need someone to help troubeshoot a problem we are having connecting a handheld windows mobile v5 devcice to a vending machine using IR.

We have two days to get this done and the peson needs to undestand IR


i have attached the errors we are getting. easy money if you know your stuff prepared to pay a full day for what could be ten minutes work


Working in Visual studio 2008  Attempting to create a program which will communicate to an IR Device using an Intermec CN3 Pocket PC running Version 5.0 Windows mobile.



Initially I had problems identifying the IR port , I had read that COM3 was the IR port on this device however I no longer think this is correct, whilst I can open,read and write port 3 I’m receiving garbage back , the fact that I can read the port when the Slave device is off also indicates that this is not the correct port.


I then tried to determine the Port from the PDA registry , this code identifies the port as 0 see code fragment below..


However when I attempt to write to  port 0 I get a generic error 1359 Identifying an Internal Error.



static void FindIrCommPort(void)


  DWORD dwSize, dwData, dwType;

  HKEY hKey;


  if(RegOpenKeyEx(HKEY_LOCAL_MACHINE,TEXT("Drivers\\BuiltIn\\IrCOMM"),0,0,&hKey) == ERROR_SUCCESS)


    dwSize = sizeof(dwData);


    if(RegQueryValueEx(hKey,TEXT("Index"),0,&dwType,(BYTE*)&dwData,&dwSize) == ERROR_SUCCESS)


       sprintf(localtext,("Found IrComm port at [%ld]"),dwData);







The log shows


[600]Found IrComm port at [0]


I have also tried connecting and releasing all Ports between 1 and 20 , ports 1,3 and 5 are active but none appear to be the IR port.


The code is C++ building for Windows mobile Pocket PC using ARM processor.

The basic structure is  CreateFile getCommState set CommState WriteFile

The Write File is failing with error 1359 Internal Error.


#define wszport L"COM0:"



commIR = CreateFile(wszport, // IR Port

                       GENERIC_READ | GENERIC_WRITE,







                if (commIR == INVALID_HANDLE_VALUE)


                                if (verboseflag)


                                                sprintf(localtext,"\nERROR Failed to  open Ir port %s Errno [%ld]\n",szPort, GetLastError());

logger(21,0, localtext);






                                sprintf(localtext,"open Ir port  success");

                                logger(22,5, localtext);



Logger shows [22]open Ir port  success


I then call GetCommState and SetCommState both of which return succesfully


            // Get the default port setting information.

                if(GetCommState(commIR, &PortDCB) == 0)


                                /*GetCommState has Failed */

                                sprintf(localtext,"ERROR GetCommState[%ld]\n", GetLastError());





                                sprintf(localtext,"GetCommState Ir port  success ");


                                logger(25,5, localtext);



                // Change the DCB structure settings.

                PortDCB.BaudRate = 2400;              // Current baud

                PortDCB.fBinary = TRUE;               // Binary mode; no EOF check

                PortDCB.fParity = TRUE;               // Enable parity checking

                PortDCB.fOutxCtsFlow = FALSE;         // No CTS output flow control

                PortDCB.fOutxDsrFlow = FALSE;         // No DSR output flow control

                PortDCB.fDtrControl = DTR_CONTROL_ENABLE;

                // DTR flow control type

                PortDCB.fDsrSensitivity = FALSE;      // DSR sensitivity

                PortDCB.fTXContinueOnXoff = TRUE;     // XOFF continues Tx

                PortDCB.fOutX = FALSE;                // No XON/XOFF out flow control

                PortDCB.fInX = FALSE;                 // No XON/XOFF in flow control

                PortDCB.fErrorChar = FALSE;           // Disable error replacement

                PortDCB.fNull = FALSE;                // Disable null stripping

                PortDCB.fRtsControl = RTS_CONTROL_ENABLE;

                // RTS flow control

                PortDCB.fAbortOnError = FALSE;        // Do not abort reads/writes on

                // error

                PortDCB.ByteSize = 8;                 // Number of bits/byte, 4-8

                PortDCB.Parity = NOPARITY;            // 0-4=no,odd,even,mark,space

                PortDCB.StopBits = ONESTOPBIT;        // 0,1,2 = 1, 1.5, 2


                // Configure the port according to the specifications of the DCB

                // structure.

                if (SetCommState(commIR, &PortDCB) == 0)


                                /*GetCommState has Failed */

                                sprintf(localtext,"\nERROR SetCommState[%ld]", GetLastError());






                                sprintf(localtext,"setCommState Ir port  success ");

                                 logger(27,5, localtext);



I then call WriteFile


logger(40,3,"About to WriteFile Bytes SendtoCommPort ");



                                                (LPVOID *) IROutBuffer,

                                                (DWORD) BytesToWrite,




                                if(retval == 0)


                                                sprintf(localtext,"ERROR SendtoCommPort:WriteFile[%ld]",GetLastError());







                                                sprintf(localtext,"OK :SendToCommPort:WriteFile byteswritten[%ld]",bytesWritten);



                                                showbytesswritten((void *) &IROutBuffer,  bytesWritten);






The logfile shows.


40]About to WriteFile Bytes SendtoCommPort

[41]ERROR SendtoCommPort:WriteFile[1359]