Last active
August 29, 2015 14:15
-
-
Save zenom/4eddc3a94494bf73af10 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
requestData = NSString.alloc.initWithData("STS\r", encoding:NSUTF8StringEncoding) | |
sample_request = ORSSerialRequest.requestWithDataToSend(requestData, userInfo: '', timeoutInterval: 3.0, responseEvaluator:-> inputData { return true }) | |
@serial.sendData(sample_request) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NSData *requestData = [@"data?" dataUsingEncoding:NSASCIIStringEncoding]; | |
ORSSerialRequest *request = | |
[ORSSerialRequest requestWithDataToSend:requestData | |
userInfo:nil | |
timeoutInterval:2.0 | |
responseEvaluator:^BOOL(NSData *inputData) { | |
if ([inputData length] != 8) return NO; | |
NSData *headerData = [inputData subdataWithRange:NSMakeRange(0, 4)]; | |
NSString *header = [[NSString alloc] initWithData:headerData encoding:NSASCIIStringEncoding]; | |
return [header isEqualToString:@"data"]; | |
}]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment