Modifying Plug-in Data for Synchronous Mode with Native Device-Side Code (Windows Embedded CE 6.0)
1/6/2010
If your plug-in communicates in synchronous mode and has a device-side component that uses native code, perform the following procedure to modify the data.
For information about the files referenced, see Components of a Plug-in.
To modify data in a synchronous-mode plug-in with native device-side code
On the desktop side, in the MyData.cs file, modify the implementation in MyData.OnGetData method to send a new command packet to the device-side component and receive a response from the device. To accomplish this, your code must include the following actions.
- Create a new variable called sendCommand of type CommandPacket, and set its CommandId property to a new command ID of your choice.
- To supply the parameters that you want to send to the device, use the CommandPacket.AddParameterxxx methods of the sendCommand object.
- Call the base.CommandTransport.ProcessCommand method to send the command packet to the device, and then assign the result to a new receivedCommand variable of type CommandPacket.
- Retrieve any parameters that the device returns, by using the CommandPacket.GetParameterxxx methods with the receivedCommand variable.
On the device side, in the Sync.cpp file, modify the implementation in the TestCallBack method to process the new command packet and return a response to the desktop-side component. To accomplish this, your code must include the following actions.
- Use the e.CommandPacketIn.CommandId property to identify the new command ID that you added to MyData.cs.
- Call the e.CommandPacketIn.GetParameterxxx methods to retrieve any parameters that were sent by the desktop-side, in the same order that they were packed into the command packet by the desktop-side component.
- Perform any necessary tasks in the device-side code.
- Create a new instance of the CommandPacket class, and then call the CommandPacket.AddParameterxxx methods to marshal the data that you want to send back to the desktop into the command packet.
- Copy the new command packet to the e.CommandPacketOut property.
To store or display any data about the device-side state in the desktop-side code, store that data in a property of the MyData class.
Note
The property must have a public accessor method for this data. If there is no specific property or public accessor method, implement it at this time.
To obtain the data stored in step 3, on the desktop side, in the MyView.cs file, modify the implementation in the MyView.OnPopulateControls method to call the public accessor methods for the MyData object's property. Then call the public accessor methods in the Windows form elements in the MyView.cs file.
(Optional) To add support for rendering the data to a data file, modify the implementation in the MyData.OnRenderGeneric method to convert the data that you stored in the MyData object's property to a set of name-value pairs. For more information, see GenericDataAcceptor in the Remote Tools Framework Native API.
Save your changes, and then rebuild the plug-in.