I am developing one application in which I need to update several parameters at once, such as engine RPM, speed, etc. using the OBD connector. I need to achieve an asynchronous command / response. To do this, I send commands using [gcdAsyncSocket writeData:data withTimeout:-1 tag:uniqueTag]; asynchronously with a unique tag.
But when the gcdAsync delegate method "socketDidReadDatawithTag" is called, it returns data, but it is not correct. eg. If I sent one command "010C \ r" (Read RPM) and "010D \ r" (speed), with tags 263 and 264, respectively, and if I analyze the response with tag 264 in socketDidReadDatawithTag, sometimes it returns me RPM data. (My response gets Mixed up or OBD Device cannot handle asynchronous response)
NSLog(@"Command Sent for Async : %@",commandString); NSData *data = [commandString dataUsingEncoding:NSASCIIStringEncoding]; long obdObjectTag = [obdObject getPIDTag];
And in socketdidReadDatawithTag data and tag do not match.
source share