Question

I am using the Redpark Serial SDK 1.4 r270 to help with i/o features for the iphone. One of the issues, that I am currently having is reading the data given using

- (void) readBytesAvailable:(UInt32)numBytes {

Here are my errors.

Feb  8 15:27:50  iapd[897] <Warning>: ERROR - /SourceCache/iapd/iapd-1065.23/iapd/IAPSession.mm:-[IAPSessionBasic _sessionBufferToAppHasSpaceAvailable] - 823 session=0x1 for connectionID=0x1e12ea00 failed to write bytes, errno = 32
Feb  8 15:27:50  iOS[7428] <Warning>: ERROR - /SourceCache/ExternalAccessory/ExternalAccessory-213/EASession.m:-[EASession dealloc] - 137 unable to close session for _accessory=0x20047eb0 and sessionID=65536
Feb  8 15:27:50  iOS[7428] <Warning>: ERROR - /SourceCache/ExternalAccessory/ExternalAccessory-213/EAOutputStream.m:-[EAOutputStream write:maxLength:] - 212 failed to write 229 bytes (wrote -1) with error 9
Feb  8 15:27:50  iOS[7428] <Warning>: ERROR - /SourceCache/ExternalAccessory/ExternalAccessory-213/EAInputStream.m:-[EAInputStream _readInputFromAccThread] - 357 error waiting for read data, errno = 9

This works perfectly works fine with a single view application.

Suppose there is a UINavigationController with view A and view B where A => B when a button is clicked. View B is using the RscMgr thread where all the magic happens to read from the serial port. At the first instance of the UINavigationController at view B, it works perfectly fine if we stay on this view. We are able to disconnect, connect the port and we will continue streaming the data.

However, if I go back to view A then back to view B. Everything goes to hell. I cannot read the data anymore from this function, and I found (MULTIPLE) errors in the console. Does anyone have a good reason as to why this happened and how we can fix it? I know we have popped the UIViewController off the stack and everything resets and the RscMgr thread is created again but nothing is being viewed. I am unsure on how to clear the buffer using the SDK since it is not provided.

Was it helpful?

Solution 2

The scope you've declared

- (void) readBytesAvailable:(UInt32)numBytes {

in is likely the problem. I would declare this somewhere that does not go away when you open and close B. Such as on the UINavigationController, or on your AppDelegate.

Better yet, create a new singleton class that manages the interface to RedPark, and query it from the rest of your app as needed.

OTHER TIPS

This is simpler than the solution above. Define your function in a different .m file, and have this launch from AppDelegate, not the ViewController.

I had this issue with former apps I wrote. The other option is to declare RscMgr in App Delegate, but then have it initialized in the given ViewController.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top