I am working on software for a new tool that interacts with some kind of scientific equipment. The user interface is implemented through a Windows CE Pocket PC (Windows CE 600 V3.01 Build 195). The instrument is configured using one end of the flexible cable, which is always connected to the SD card slot on the PC. A cable enters the instrument and the other end connects to the installed SD card when it is present. The SD card contains a chip for use with the tool, as well as software / firmware updates as necessary, and a data file related to the chip. I have C # software that starts when WinCE loads. This application checks for the presence of an SDMMC card, because it depends on the data related to the accompanying chip for certain functions.
My problem. If an SD card is inserted at the other end of the flex cable when WinCE boots up, winCE detects the presence of the card and the \ SDMMC folder is created, allowing the software to read the data. If only a flexible cable is connected, but the SDMMC card is not present at the other end, Windows does not create a folder. This is what I expect. But our field engineers change the map for various reasons to replace the chip while the software is active. This is a problem if the windows load before the card is inserted. Due to the flexible cable, WinCE never detects that a card is inserted. He also never discovers that he has been deleted.
The software checks the SD card every 5 seconds. The firmware can determine through bits if a card is inserted, and it transfers this information to the software. If the card was previously missing, now it is detected, but the \ SDMMC folder is missing, I would like the software to call WinCE in order to try to detect again. I was thinking about using registry values, but it is not clear what the value of HKEY_LOCAL_MACHINE SDMMc can be written. I'm also not quite sure what the meanings mean. Can they be reset? I see that the Storage Manager registry will detect this, as shown below:
[HKEY_LOCAL_MACHINE\System\StorageManager\Profiles\SDMMC] "Name"="SD MMC device" "Folder"="SD Card
Is there any way to read / write this registry in order to click winCE to see that the card is inserted on the other end of the cable? AM I totally disagree with this thought? Is there any other way to do this?
Sorry for the long question. I usually play at the application level. The population of this problem did not give me the answers that I need, although perhaps I do not know enough to ask the right questions. Thanks for any help you can give me.
UPDATE: I am still trying to find a solution to this problem. My current thought is to get Windows CE to re-enumerate the device when my device firmware detects that a card is inserted. MY code is requesting firmware to receive a notification about this in my C # application. For my tool / application, the SD card is always in "Dsk2:". When a C # application receives a notification about inserting an SD card, it calls a method that performs the following actions:
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
In the above case, the call to CreateFile () failed with error 55: "The specified network resource or device is no longer available."
MY QUESTIONS: Am I trying to make re-enumeration of a device reasonable? Does CreateFile mean that I have to make an ActivateDevice () call? I see an example here: Problems with loading the device driver at startup - WM6.1 of someone calling ActivateDevice () from C # code and wondering if this will take care of the problem of getting WIndows CE to recognize that the SD card now inserted. Can someone help me understand what parameters need to be sent to the ActivateDevice () window? I do not agree with this approach?
This is a new territory for me, and I appreciate any help you can provide. Thanks.