0

I was using this legacy code:

SerialPort serialPort = new SerialPort();
serialPort.BaudRate = 19200;
serialPort.Handshake = Handshake.XOnXOff;

...but trying to port it to VS 2013 / .NET 4.5.1 in the "Core" (Portable Class Library) portion of a Xamarin solution, I get, "The name 'Handshake' does not exist in the current context"

According to this, the Handshake enum is in System.IO.Ports namespace, but adding that to my usings evokes "The type or namespace name 'Ports' does not exist in the namespace 'System.IO' (are you missing an assembly reference?)"

Perhaps I am missing an assembly reference? The link above says it's in System. My only reference is ".NET Portable Subset" which I assume (I know, I know, when you ASSume you Aynchronously Syncopate Sinkholes or something like that) would have System embedded in it.

When I r-click References and select Add Reference..., the options proffered are somewhat slight:

enter image description here

So...how can I use Handshake.XOnXOff? If I can't, what are my viable options?

B. Clay Shannon-B. Crow Raven
  • 8,547
  • 144
  • 472
  • 862
  • 1
    I don't believe that Windows Phone supports Serial IO. http://msdn.microsoft.com/en-us/library/windowsphone/develop/jj207211%28v=vs.105%29.aspx – Jason Mar 21 '14 at 22:53
  • Oh, yeah, this is code (originally for a handheld device) that prints labels on a belt printer. I reckon a phone/tablet would be able to "air print" to a more conventional type of printer...or, perhaps, to retain the functionality, a belt printer could be peripheraled to a phablet or tablet? – B. Clay Shannon-B. Crow Raven Mar 21 '14 at 23:13
  • Coincidentally, both relevant disambiguations of PCL come to mind in this scenario (Portable Class Library and Printer Command Language). – B. Clay Shannon-B. Crow Raven Mar 21 '14 at 23:46

1 Answers1

2

I don't think you're going to be able to implement print functionality in a platform agnostic way. Your best bet would be to define some sort of IPrinting interface. That interface can be implemented in a platform specific library, then a reference can be passes into your PCL, so that the PCL can hand off the printing duties via the Interface.

Jason
  • 86,222
  • 15
  • 131
  • 146
  • How would that look? Each device calls a method like PrintLabel(iPhone) or PrintLabel(Android) or PrintLabel(WP8), - etc., perhaps - and then the core code (that would naturally do such underhanded, I mean low-level, things) then calls the device-specific code? Or...??? – B. Clay Shannon-B. Crow Raven Mar 21 '14 at 23:49
  • Yes, something like that. – Jason Mar 21 '14 at 23:59