Note that there are some explanatory texts on larger screens.

plurals
  1. POStar Micronics TSP650II bluetooth printer, can't write to EASession.OutputStream
    text
    copied!<p>I'm trying to print a label with a Star Micronics TSP650II printer in a monotouch app.</p> <p>The problem is that <code>session.OutputStream.HasSpaceAvailable()</code> always returns false. What am I missing?</p> <p>the C# code I have goes something like this (cut for simplicity):</p> <pre><code> var manager = EAAccessoryManager.SharedAccessoryManager; var starPrinter = manager.ConnectedAccessories.FirstOrDefault (p =&gt; p.Name.IndexOf ("Star") &gt;= 0); // this does find the EAAccessory correctly var session = new EASession (starPrinter, starPrinter.ProtocolStrings [0]); // the second parameter resolves to "jp.star-m.starpro" session.OutputStream.Schedule (NSRunLoop.Current, "kCFRunLoopDefaultMode"); session.OutputStream.Open (); byte[] toSend = GetInitData(); // this comes from another project where the same printer with ethernet cable was used in a windows environment and worked, not null for sure if (session.OutputStream.HasSpaceAvailable()) { int bytesWritten = session.OutputStream.Write (toSend, (uint)stillToSend.Length); if (bytesWritten &lt; 0) { Debug.WriteLine ("ERROR WRITING DATA"); } else { Debug.WriteLine("Some data written, ignoring the rest, just a test"); } } else Debug.WriteLine ("NO SPACE"); // THIS ALWAYS PRINTS, the output stream is never ready to take any output </code></pre> <p>UPDATE: I was able to work-around this problem by binding Star Micronics iOS SDK to my project, but that's less than ideal as it adds 700K to the package for something that should work without that binding.</p> <p>UPDATE 2: I've been getting requests for the binding code. I still strongly recommend you try to figure out the bluetooth connectivity and not use the binding but for those who are brave enough, <a href="https://www.dropbox.com/s/fyk2xlcyyqhgoxb/StarMicronics%20650II%20BT%20-%20Xamarin%20Binding.zip?dl=0" rel="nofollow">here it is</a>.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload