Problem when serial port already active

Questions, FAQ, Feature Requests and Troubleshooting for Airconsole

Moderator: sergey

BillFulton
Posts: 12
Joined: Fri Mar 27, 2015 10:00 am

Problem when serial port already active

Postby BillFulton » Thu Apr 30, 2015 3:00 am

I have a situation where data is continuously generated by a serial port connected to anAirConsole 2, and the app I’m developing must be able to start up at any time, even if data is already being generated. My app reads and analyses the data stream using bluetooth. The app works perfectly if the app is started (and a connection is established) before any data is generated. However, things go wrong if the serial port is already generating data before the app is started.

If the app is started before data is generated by the port, events occur in the expected order:

1. I instantiate an airconsoleMgr object, disable WiFi, assign a delegate and call scanForDevices.
2. deviceAdded is invoked, where I instantiate an airconsoleSession object, assign a delegate, setLineParameters, setFlowControl and call the connect method.
3. sessionDidConnect is invoked, where I call stopScanning.
Note: The call to stopScanning, as I notice is mentioned in another post here, surprisingly causes deviceRemoved to be invoked, but this seems to have no bad effect.
4. sessionBytesAvailable is repeatedly invoked, where I read the incoming data.

However if data is already being generated before the app starts, the order is different:
After DeviceAdded runs, there is a call to sessionBytesAvailable, then a call to sessionDidConnect, followed by repeated calls to sessionBytesAvailable. (Surely this is not what is supposed to happen?) Also, the data received in all calls to sessionBytesAvailable is completely garbled — regardless of which flow control method is chosen at both ends.

The workarounds I tried had no effect:

1. Calling the flush method just before connecting.
2. Dismissing calls to sessionBytesAvailable until sessionDidConnect has completed (but flushing).

My app also needs to automatically re-connect when the device briefly goes out of range and then returns within range. I can’t do this because of the same problem: when I re-connect, data generation is already in progress, so only garbled data is received from then on.

Is this a known problem, is there a workaround or when could a fix be expected? It’s a real showstopper for my app.

Fwiw here is my test setup: An AirConsole 2 is connected to a Digitech Serial to USB adaptor which is connected to a USB hub which connects to a USB port on my Mac. Data is generated by the CoolTerm app, sending the contents of a large text file to the port. My app runs under iOS8.2 on a (physical) iPhone5. 4800 baud, 8 bits, no parity, 1 stop bit, XON, DTR or no flow control.

Help appreciated. :)

Bill

BillFulton
Posts: 12
Joined: Fri Mar 27, 2015 10:00 am

Re: Problem when serial port already active

Postby BillFulton » Thu Apr 30, 2015 3:50 am

Removing the call to stopScanning did not help. I've noticed that about one time in twenty it actually does work. Maybe a timing issue in the SDK? I'm using 1.5.0.

daniel
Posts: 127
Joined: Wed Jul 27, 2011 9:33 am

Re: Problem when serial port already active

Postby daniel » Thu Apr 30, 2015 9:00 am

The latest published SDK on the website (http://www.get-console.com/airconsole) is 1.51 not 1.5.0 so not sure if you have a typo in the comment above?

We do have a pre-release 1.52 version which fixes the stopScanning call removing items from the device list. I'm not sure why this isn't on the website yet, but I will arrange for it to go up shortly.

We are hoping to make a further update to the SDK in the next 2-3 weeks which should add some new features and hopefully fix the ordering of delegate calls during connect. I don't think either of these is related to your issue though :-(

If you are getting completely corrupted data (e.g. your app is sending a text file and you are getting random binary) then it sounds like a baud mismatch style of error - is it possible to set the default baud rate on the Airconsole to 4800? Go to http://192.168.10.1/ and navigate to the serial page. Does this fix the garbled output issue?

BillFulton
Posts: 12
Joined: Fri Mar 27, 2015 10:00 am

Re: Problem when serial port already active

Postby BillFulton » Thu Apr 30, 2015 5:17 pm

Many thanks @Daniel.

I set default baud rate to 4800 and flow control to DSR, over WiFi, and now it works more often, fairly often in fact, but mostly it works correctly for 30-50 executions of sessionBytesAvailable then disconnects. If I move out of range and then back into range, the logic of my app re-connects but typically there is an immediate disconnect again, or if it does not disconnect then I get completely garbled characters from then on. (As I say, it always works if the app is started before incoming data appears.)

Even if it had worked, setting a default rate would not have been a permanent solution and a fix is needed. Will you be able to log it with the development team as a showstopper bug? Some sort of race condition perhaps. Should be easy to reproduce from my earlier description.

You are right that my SDK is not V1.5.0, I seem to have got that number from the Android SDK, sorry. I can't seem to find any record of the iOS version number in the SDK download, but libAirconsole is 1,411,172 bytes, dated 15 Aug 2014. Which version is that?

Bill.

BillFulton
Posts: 12
Joined: Fri Mar 27, 2015 10:00 am

Re: Problem when serial port already active

Postby BillFulton » Thu Apr 30, 2015 7:22 pm

OK @Daniel, I think it was V1.43. Was this one of the bugs listed as fixed in V1.51? Supporting a robust and reliable
bluetooth connection would seem to be a priority numero uno? :)

Bill.

BillFulton
Posts: 12
Joined: Fri Mar 27, 2015 10:00 am

Re: Problem when serial port already active

Postby BillFulton » Fri May 01, 2015 8:58 pm

@Daniel, I tried it with SDK 1.51. The problem is the same, although it does not fail every time, just most of the time. What do I need to do to log this bug with development? Thanks, Bill.

daniel
Posts: 127
Joined: Wed Jul 27, 2011 9:33 am

Re: Problem when serial port already active

Postby daniel » Sat May 02, 2015 9:02 pm

Hi Bill,

This forum is primarily for user-based support. You can log a ticket at http://support.get-console.com/ which will then get into the development queue.

A few other things:
- we have tried to replicate this issue, but haven't managed to yet. I'm curious about the nature of the corruption to determine where it is happening - e.g. is the corrupt data you receive actually part of the file (e.g. out of order, sections missing) or is it completely random data?
- a useful troubleshooting method can be to connect your Airconsole to a private server - this way you will get the serial data sent both across Bluetooth and to your server. It will help to determine if the issue is on the serial port side or the Bluetooth side

BillFulton
Posts: 12
Joined: Fri Mar 27, 2015 10:00 am

Re: Problem when serial port already active

Postby BillFulton » Fri May 08, 2015 1:37 am

Many thanks @daniel. Appreciated. I tried the Get Console app on my iPhone using the exact same test environment -- it works perfectly where my app doesn't. So either it is not an SDK bug at all, or if it is then the Get Console guys found a workaround.

Will work on further isolating the problem on my app and submit a support ticket if needed.

Bill

daniel
Posts: 127
Joined: Wed Jul 27, 2011 9:33 am

Re: Problem when serial port already active

Postby daniel » Tue May 12, 2015 11:19 pm

Not sure if this helps, but the Get Console app internally uses the Airconsole SDK for Airconsole connections.


Return to “Airconsole”

Who is online

Users browsing this forum: No registered users and 8 guests