[MonoTouch] EAAccessory

danmiser danmiser at gmail.com
Tue Mar 6 15:05:58 UTC 2012


I have the code narrowed down to a pretty simple test case. Unfortunately, it
relies on having the printer that I'm using. If anyone has access to the
source code for the MT EAAccessory code, can you take a look at what's
happening to the creation/assignment of EASession OutputStream and
InputStream. They are null when getting created the second time.

My code looks like this:

private EAAccessory GetConnectedPrinter() {
  EAAcessory accessory = null;
  foreach (var obj in
EAAcessoryManager.SharedAccessoryManager.ConnectedAccessories) { 
    if (accessory != null) break;
    foreach (var p in obj.ProtocolStrings) {
      if (p.Contains("com.bluebamboo.p25i")) {
        accessory = obj;
        break;
      }
    }
  return accessory;
}

Then in a button TouchUpInside event:
EAAccessory accessory = GetConnectedPrinter(); 
// Ignore error check for test (printer is on so accessory is set properly
EASession session = new EASession(accessory, "com.bluebamboo.p25i");

The first time, session is created and OutputStream and InputStream are
created.
The second time, session is created, but OutputStream and InputStream are
null. This creates problems later on in the code because I need to write on
the OutputStream.

Other notes:
* It doesn't matter if the session variable is declared at the class level
or inside the method.
* It doesn't matter if I do session.Dispose() and set it to null. It still
returns null for OutputStream and InputStream on the second create.
* On a semi-related note, the Delegate and OnEvent methods aren't firing the
events in the MT sample, but they do fire in the XCode sample.

I can't find the code where I originally got the sample. I thought it was
posted from here on a gist, but my google fu is weak today. :(

Hopefully this is enough to go on to have the devs do a quick code review of
the EASession class at least. If you need more details, I'm happy to provide
them.


--
View this message in context: http://monotouch.2284126.n4.nabble.com/EAAccessory-tp4448799p4450129.html
Sent from the MonoTouch mailing list archive at Nabble.com.


More information about the MonoTouch mailing list