Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to force winCE to see SD/MMC card after startup
    text
    copied!<p>I am working on the software for a new instrument that interacts with some scientific equipment. The user interface is via Windows CE pocket PC (Windows CE 600 V3.01 Build 195). The instrument is setup with one end of a flex cable always plugged into the SD card slot on the PC. The cable runs into the instrument, and the other end plugs into a mounted SD card when it is present. The SD card contains a chip for use with the instrument, as well as software/firmware updates as needed and a data file pertaining to the chip. I have a c# software application that is run when WinCE boots. This application checks for the presence of the SDMMC card as it depends on data related to the accompanying chip for certain functionality.</p> <p>My problem: If the SD card is inserted into the other end of the flex cable when WinCE boots, winCE detects the card's presence and the \SDMMC folder is created allowing software to read the data. If only the flex cable is plugged in, but the SDMMC card is NOT present at the other end, Windows does not create the folder. This I expect. But our field engineers will swap the card in and out for various reasons to replace the chip while the software is active. This is a problem if windows is booted before the card is inserted. Because of the flex cable, WinCE never detects that the card has been inserted. It also never detects that it was removed. </p> <p>The software polls the SD card every 5 seconds. The firmware can tell via the setting of bits if the card is inserted, and it relays this info to software. If the card had previously been absent, is now detected, but the \SDMMC folder is not present, I'd like software to trigger WinCE to attempt detection again. I thought about using registry values but am not clear the presense of the HKEY_LOCAL_MACHINE SDMMc value can be written. I"m also not quite sure what the values mean. Can these be reset? I see the Storage Manager Registry would define this as below:</p> <pre><code>[HKEY_LOCAL_MACHINE\System\StorageManager\Profiles\SDMMC] "Name"="SD MMC device" "Folder"="SD Card </code></pre> <p>Is there someway to read/write this registry to poke winCE to see that a card has been inserted at the other end of the cable? AM I totally off base with this thought? Is there some other way to do this?</p> <p>I apologize for the long question. I generally play at the application level. Googling this issue has not given me the answers I need, though perhaps I don't know enough to ask the right questions. Thanks for any help you can give me.</p> <p>UPDATE: I'm still trying to find a resolution to this problem. My current thought is to force Windows CE to re-enumerate the device when my instrument firmware detects the card has been inserted. MY code polls firmware to receive notice of this in my c# application. For my instrument/application the SD Card is always in "Dsk2:". When the c# application receives notice the SD Card has been inserted it calls a method that does the following:</p> <p>CODE</p> <pre><code> hDevice = CreateFile("\\Dsk2:", (0x80000000) | (0x40000000), 0, IntPtr.Zero, OPEN_EXISTING, 0, IntPtr.Zero); if (hDevice == INVALID_HANDLE_VALUE) { int hDeviceError = Marshal.GetLastWin32Error(); // THis is an error - call GetLastERror to find // out what happened. using (StreamWriter bw = new StreamWriter(File.Open(App.chipDebugFile, FileMode.Append))) { String iua = "DevDriverInterface: error from CreateFile: " + hDeviceError.ToString(); bw.WriteLine(iua); } return false; } bResult = DeviceIoControl(hDevice, IOCTL_DISK_UPDATE_PROPERTIES, null, 0, null, 0, ref nBytesReturned, nOverLapped); </code></pre> <p>/CODE</p> <p>IN the above, the CreateFile() call fails with error 55: "The Specified network resource or device is no longer available". </p> <p>MY questions: Is what I'm trying to do reasonable to re-enumerate the device? Does the CreateFile error indicate I should make an ActivateDevice() call instead? I see an example here: <a href="https://stackoverflow.com/questions/3585333/problems-getting-a-device-driver-to-load-at-startup-wm6-1">Problems getting a device driver to load at startup - WM6.1</a> of someone calling ActivateDevice() from c# code and wonder if that would take care of the problem of getting WIndows CE to recognize that an SD card is now inserted. Can anyone help me understand what parameters to send to window's ActivateDevice() command? Am I offbase with this approach?</p> <p>This is all new territory for me and I appreciate any help you can provide. Thanks.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload