1

I've figured out how to enable i2of5 using the ScanAPI, but it doesn't seem to have a clear example of updating the length parameter associated with the i2of5 barcode type.

I used the following to 'enable' i2of5...

[self.ScanApi postSetSymbologyInfo:_deviceInfoToTrigger SymbologyId:kSktScanSymbologyStandard2of5 Status:YES Target:self Response:@selector(onSetSymbology:)];

ScanAPI Reference

I would like to set the length parameter (L1) to 10. Using the documentation information which specifies an array that can be passed in. What I would like to know is what API call is used to pass this parameter array in?

Here's what I've tried, setting the length to 10 (0xA0):

unsigned char deviceCommand[] = { 0x09,0xC6,0x04,0x00,0xFF,0x16,0xA0,0x00,0x00 };
[self.ScanApi postGetDeviceSpecific:_deviceInfoToTrigger Command:deviceCommand Length:9 Target:self Response:@selector(onSetDeviceSpecific:)];

I am able to configure it easily with the barcodes in the Socket Mobile command barcodes document but I would like to do this automatically within our application in both Android and iOS. Working in iOS right now (obviously).

Mark
  • 190
  • 1
  • 11
  • This is a really good question - definitely one of the more advanced options you can configure. Thanks for posting what you had already tried, it was very helpful – Enrico Aug 23 '16 at 16:45

1 Answers1

1

You were very close. Device Specific is the correct property for configuring the length

It should work if you change your two lines as follows

// Leave the L2 parameter ID unchanged
// 10 is 0x0A not 0xA0
unsigned char deviceCommand[] = { 0x09, 0xC6, 0x04, 0x00, 0xFF, 0x16, 0x0A, 0x17, 0x00 };

// You need to set the device specific property, not get it
[self.ScanApi postSetDeviceSpecific:_deviceInfoToTrigger Command:deviceCommand Length:9 Target:self Response:@selector(onSetDeviceSpecific:)];

EDIT

As you correctly pointed out, postSetDeviceSpecific does not exist. You will need to add the following to your copy of ScanApiHelper.mm

/**
 * postSetDeviceSpecific
 *
 * post a command specific to a certain type of scanner
 * The command is usually a series of bytes that are understandable only
 * by one particular type of scanner therefore the type of scanner must be
 * checked prior calling this method
 *
 * @param deviceInfo to send the command to
 * @param pCommand pointer to the bytes to send to the device
 * @param length of the command in bytes
 * @param target main object receiving the response
 * @param response selector invoked when the response is received
 */
-(void)postSetDeviceSpecific:(DeviceInfo*)deviceInfo Command:(unsigned char*)pCommand Length:(int) length Target:(id)target Response:(SEL) response{
    ISktScanObject*scanObj=[SktClassFactory createScanObject];
    [[scanObj Property]setID:kSktScanPropIdDeviceSpecific];
    [[scanObj Property]setType:kSktScanPropTypeArray];
    [[scanObj Property]setArray:pCommand Length:length];
    CommandContext* command=[[CommandContext alloc]initWithParam:FALSE
                                                         ScanObj:scanObj
                                                      ScanDevice:[deviceInfo getSktScanDevice]
                                                          Device:deviceInfo
                                                          Target:target
                                                        Response:response];

    [self addCommand:command];
#if __has_feature(objc_arc)
#else
    [command release];
#endif

}
Enrico
  • 10,377
  • 8
  • 44
  • 55
  • Thanks @Enrico! Just downloaded the latest ScanAPI 10.3.41 and it doesn't have a postSetDeviceSpecific method??? What am I missing? – Mark Aug 23 '16 at 17:33
  • You are right. `ScanApiHelper` doesn't have a `postSetDeviceSpecific` method because it's rarely used. I'll update my answer with the method you'll need to add to your copy of `ScanApiHelper`. I'm not an iOS developer, so let me know if I've made any mistakes – Enrico Aug 23 '16 at 18:03
  • Ack! Sorry about that. I'll take another look tomorrow and see if I can figure out what's not working – Enrico Aug 23 '16 at 20:56
  • 1
    Your code was the solution! Had some other problems with the project (cocoapods) that were unrelated but it did work. Thanks! – Mark Aug 23 '16 at 21:02