From 92ba1ee26ecd79412c91ffbb59aabd12a7c28e5a Mon Sep 17 00:00:00 2001 From: Adam Shapiro Date: Fri, 4 Dec 2015 14:34:54 -0800 Subject: Updates to Barcode Scanner Sample Changes to BarcodeScanner.sln, PosEvents.cpp, SampleBarcodeScannerDrv.vcxproj and .filters, and the sources file. --- pos/drivers/barcodescanner/BarcodeScanner.sln | 24 +++-- pos/drivers/barcodescanner/PosEvents.cpp | 15 ++-- .../barcodescanner/SampleBarcodeScannerDrv.vcxproj | 100 +++++++++++++++++++-- .../SampleBarcodeScannerDrv.vcxproj.Filters | 8 +- pos/drivers/barcodescanner/sources | 38 ++++++++ 5 files changed, 160 insertions(+), 25 deletions(-) create mode 100644 pos/drivers/barcodescanner/sources diff --git a/pos/drivers/barcodescanner/BarcodeScanner.sln b/pos/drivers/barcodescanner/BarcodeScanner.sln index 1072df65..390805d5 100644 --- a/pos/drivers/barcodescanner/BarcodeScanner.sln +++ b/pos/drivers/barcodescanner/BarcodeScanner.sln @@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 2013 VisualStudioVersion = 12.0 MinimumVisualStudioVersion = 12.0 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SampleBarcodeScannerDrv", "SampleBarcodeScannerDrv.vcxproj", "{30F6FA25-B31E-46B0-AFBB-2AC9BA3319F0}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SampleBarcodeScannerDrv", "SampleBarcodeScannerDrv.vcxproj", "{6551F16A-3A12-4CDA-B585-2E2F813CF25E}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -11,16 +11,22 @@ Global Release|Win32 = Release|Win32 Debug|x64 = Debug|x64 Release|x64 = Release|x64 + Debug|Arm = Debug|Arm + Release|Arm = Release|Arm EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {30F6FA25-B31E-46B0-AFBB-2AC9BA3319F0}.Debug|Win32.ActiveCfg = Debug|Win32 - {30F6FA25-B31E-46B0-AFBB-2AC9BA3319F0}.Debug|Win32.Build.0 = Debug|Win32 - {30F6FA25-B31E-46B0-AFBB-2AC9BA3319F0}.Release|Win32.ActiveCfg = Release|Win32 - {30F6FA25-B31E-46B0-AFBB-2AC9BA3319F0}.Release|Win32.Build.0 = Release|Win32 - {30F6FA25-B31E-46B0-AFBB-2AC9BA3319F0}.Debug|x64.ActiveCfg = Debug|x64 - {30F6FA25-B31E-46B0-AFBB-2AC9BA3319F0}.Debug|x64.Build.0 = Debug|x64 - {30F6FA25-B31E-46B0-AFBB-2AC9BA3319F0}.Release|x64.ActiveCfg = Release|x64 - {30F6FA25-B31E-46B0-AFBB-2AC9BA3319F0}.Release|x64.Build.0 = Release|x64 + {6551F16A-3A12-4CDA-B585-2E2F813CF25E}.Debug|Win32.ActiveCfg = Debug|Win32 + {6551F16A-3A12-4CDA-B585-2E2F813CF25E}.Debug|Win32.Build.0 = Debug|Win32 + {6551F16A-3A12-4CDA-B585-2E2F813CF25E}.Release|Win32.ActiveCfg = Release|Win32 + {6551F16A-3A12-4CDA-B585-2E2F813CF25E}.Release|Win32.Build.0 = Release|Win32 + {6551F16A-3A12-4CDA-B585-2E2F813CF25E}.Debug|x64.ActiveCfg = Debug|x64 + {6551F16A-3A12-4CDA-B585-2E2F813CF25E}.Debug|x64.Build.0 = Debug|x64 + {6551F16A-3A12-4CDA-B585-2E2F813CF25E}.Release|x64.ActiveCfg = Release|x64 + {6551F16A-3A12-4CDA-B585-2E2F813CF25E}.Release|x64.Build.0 = Release|x64 + {6551F16A-3A12-4CDA-B585-2E2F813CF25E}.Debug|Arm.ActiveCfg = Debug|Arm + {6551F16A-3A12-4CDA-B585-2E2F813CF25E}.Debug|Arm.Build.0 = Debug|Arm + {6551F16A-3A12-4CDA-B585-2E2F813CF25E}.Release|Arm.ActiveCfg = Release|Arm + {6551F16A-3A12-4CDA-B585-2E2F813CF25E}.Release|Arm.Build.0 = Release|Arm EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/pos/drivers/barcodescanner/PosEvents.cpp b/pos/drivers/barcodescanner/PosEvents.cpp index 1d2443bb..e436099c 100644 --- a/pos/drivers/barcodescanner/PosEvents.cpp +++ b/pos/drivers/barcodescanner/PosEvents.cpp @@ -38,11 +38,11 @@ VOID EvtOnBarcodeScanDataRetrieved(_In_ WDFDEVICE Device) // PosEventType::ReleaseDeviceRequested // The following shows an example of sending barcode scan data - WCHAR exampleData[] = L"]0A12345"; - WCHAR exampleDataLabel[] = L"12345"; + CHAR exampleData[] = "]0A12345"; + CHAR exampleDataLabel[] = "12345"; // total size is the struct plus the size of the two strings (minus the null terminators which aren't transmitted). - size_t totalSize = sizeof(PosBarcodeScannerDataReceivedEventData) + sizeof(exampleData) - sizeof(WCHAR) + sizeof(exampleDataLabel) - sizeof(WCHAR); + size_t totalSize = sizeof(PosBarcodeScannerDataReceivedEventData) + sizeof(exampleData) - sizeof(CHAR) + sizeof(exampleDataLabel) - sizeof(CHAR); // PosCx supports two methods of pending the event data -- one where it takes the WDFMEMORY for the event, and the other where it creates it @@ -72,20 +72,23 @@ VOID EvtOnBarcodeScanDataRetrieved(_In_ WDFDEVICE Device) return; } + // Calculate data and label sizes + size_t exampleDataByteCount = sizeof(exampleData) - sizeof(CHAR); + size_t exampleLabelByteCount = sizeof(exampleDataLabel) - sizeof(CHAR); + PosBarcodeScannerDataReceivedEventData* eventHeader = (PosBarcodeScannerDataReceivedEventData*)eventData; eventHeader->Header.EventType = PosEventType::BarcodeScannerDataReceived; eventHeader->Header.DataLength = (UINT32)totalSize; eventHeader->DataType = BarcodeSymbology::Ean13; + eventHeader->ScanDataLength = (UINT32)exampleDataByteCount; + eventHeader->ScanDataLabelLength = (UINT32)exampleLabelByteCount; // These use memcpy because wcscpy would append the null terminator and the event data doesn't use it BYTE* eventScanData = eventData + sizeof(PosBarcodeScannerDataReceivedEventData); - size_t exampleDataByteCount = sizeof(exampleData) - sizeof(WCHAR); memcpy(eventScanData, exampleData, exampleDataByteCount); BYTE* eventLabelData = eventScanData + exampleDataByteCount; - size_t exampleLabelByteCount = sizeof(exampleDataLabel) - sizeof(WCHAR); memcpy(eventLabelData, exampleDataLabel, exampleLabelByteCount); - // This call actually pends the data to be send to the WinRT APIs. status = PosCxPutPendingEventMemory(Device, SCANNER_INTERFACE_TAG, eventMemory, POS_CX_EVENT_ATTR_DATA); diff --git a/pos/drivers/barcodescanner/SampleBarcodeScannerDrv.vcxproj b/pos/drivers/barcodescanner/SampleBarcodeScannerDrv.vcxproj index cf354ec3..555c9289 100644 --- a/pos/drivers/barcodescanner/SampleBarcodeScannerDrv.vcxproj +++ b/pos/drivers/barcodescanner/SampleBarcodeScannerDrv.vcxproj @@ -17,20 +17,44 @@ Release x64 + + Debug + Arm + + + Release + Arm + - {E08242CA-297F-4C12-A99F-EC78245117F5} + {6551F16A-3A12-4CDA-B585-2E2F813CF25E} $(MSBuildProjectName) 2 Debug Win32 - {294BDD9E-A272-4E3A-804F-5C117FC85E08} + {ABA12C7E-CC0F-45F2-881E-9A2C7C7EFEFC} + + Windows10 + False + Universal + UMDF + WindowsUserModeDriver10.0 + DynamicLibrary + + + Windows10 + True + Universal + UMDF + WindowsUserModeDriver10.0 + DynamicLibrary + Windows10 False - Desktop + Universal UMDF WindowsUserModeDriver10.0 DynamicLibrary @@ -38,7 +62,7 @@ Windows10 True - Desktop + Universal UMDF WindowsUserModeDriver10.0 DynamicLibrary @@ -46,7 +70,7 @@ Windows10 False - Desktop + Universal UMDF WindowsUserModeDriver10.0 DynamicLibrary @@ -54,7 +78,7 @@ Windows10 True - Desktop + Universal UMDF WindowsUserModeDriver10.0 DynamicLibrary @@ -63,6 +87,12 @@ $(IntDir) + + + + + + @@ -76,6 +106,12 @@ + + SampleBarcodeScannerDrv + + + SampleBarcodeScannerDrv + SampleBarcodeScannerDrv @@ -88,6 +124,18 @@ SampleBarcodeScannerDrv + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + + + + _DllMainCRTStartup@12 + _DllMainCRTStartup + + _DllMainCRTStartup@12 @@ -112,6 +160,34 @@ _DllMainCRTStartup + + + Sync + true + Level4 + %(AdditionalIncludeDirectories);$(DDK_INC_PATH);$(SDK_INC_PATH)\pos\1.1;..\inc + + + %(AdditionalIncludeDirectories);$(DDK_INC_PATH);$(SDK_INC_PATH)\pos\1.1;..\inc + + + %(AdditionalIncludeDirectories);$(DDK_INC_PATH);$(SDK_INC_PATH)\pos\1.1;..\inc + + + + + Sync + true + Level4 + %(AdditionalIncludeDirectories);$(DDK_INC_PATH);$(SDK_INC_PATH)\pos\1.1;..\inc + + + %(AdditionalIncludeDirectories);$(DDK_INC_PATH);$(SDK_INC_PATH)\pos\1.1;..\inc + + + %(AdditionalIncludeDirectories);$(DDK_INC_PATH);$(SDK_INC_PATH)\pos\1.1;..\inc + + Sync @@ -168,6 +244,18 @@ %(AdditionalIncludeDirectories);$(DDK_INC_PATH);$(SDK_INC_PATH)\pos\1.1;..\inc + + + %(AdditionalDependencies);$(SDK_LIB_PATH)\pos\1.1\poscxstub.lib + exports.def + + + + + %(AdditionalDependencies);$(SDK_LIB_PATH)\pos\1.1\poscxstub.lib + exports.def + + %(AdditionalDependencies);$(SDK_LIB_PATH)\pos\1.1\poscxstub.lib diff --git a/pos/drivers/barcodescanner/SampleBarcodeScannerDrv.vcxproj.Filters b/pos/drivers/barcodescanner/SampleBarcodeScannerDrv.vcxproj.Filters index 4268199b..9b16c2dc 100644 --- a/pos/drivers/barcodescanner/SampleBarcodeScannerDrv.vcxproj.Filters +++ b/pos/drivers/barcodescanner/SampleBarcodeScannerDrv.vcxproj.Filters @@ -3,19 +3,19 @@ cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx;* - {47F49773-F319-4591-B32D-BA38E9E75F22} + {A8857C1C-EE8A-44D9-8EB2-A78D510F4E43} h;hpp;hxx;hm;inl;inc;xsd - {74AA7E37-6BDE-408A-AF19-36CBA1A80849} + {04004AF3-4725-41BB-932B-DB734ACB684E} rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms;man;xml - {58E2BE2E-4AAA-48F9-95E8-65E24E014E15} + {9474798F-C7E3-4CC5-B3A4-D524A84DCD5F} inf;inv;inx;mof;mc; - {E145DF39-11C3-4472-BDA5-35448FA78D69} + {E2A7C868-3D64-4BE3-9F17-CB286F80D354} diff --git a/pos/drivers/barcodescanner/sources b/pos/drivers/barcodescanner/sources new file mode 100644 index 00000000..11c406dc --- /dev/null +++ b/pos/drivers/barcodescanner/sources @@ -0,0 +1,38 @@ +TARGETNAME=SampleBarcodeScannerDrv +TARGETTYPE=DYNLINK + +TARGET_DESTINATION=NTTEST\drivers\pos\Samples +DLLENTRY=_DllMainCRTStartup +DLLDEF=exports.def + +DDK_TARGET_PLATFORM=Universal + +UMDF_VERSION_MAJOR=2 + +USE_MSVCRT=1 +USE_NATIVE_EH=1 + +USE_STL=1 +STL_VER=STL_VER_CURRENT + + +MSC_WARNING_LEVEL=/W4 /WX + +INCLUDES=$(INCLUDES);\ + $(DDK_INC_PATH); \ + $(SDK_INC_PATH)\pos\1.1; \ + ..\inc; \ + +PRECOMPILED_INCLUDE=pch.h +PRECOMPILED_CXX=1 + +SOURCES= \ + Driver.cpp \ + Device.cpp \ + File.cpp \ + Ioctl.cpp \ + IoRead.cpp \ + PosEvents.cpp \ + +TARGETLIBS= \ + $(SDK_LIB_PATH)\pos\1.1\poscxstub.lib -- cgit v1.3.1