Deploying an app to Cerbuino Bee (Noob)


I have been banging away at my first .net MF app (extender module, serial GPS and a 4x20 LCD). Everything works great. About to test out the newly-minted uSD bits. However, I cant deploy the app to the device properly. It seems to download and run while the USB cable is connected. But when I reset it, or run it on batteries, it doesn’t start up (LCD blank).

What can I be doing wrong?

Any help would be greatly appreciated.

Not enough power is most likely, but please show your code.

Batteries - yes, please elaborate.

But the more likely cause is your serial handling. Please confirm that you subscribe to the datarecieved event before you open the serial port. That is a known bad order, that becomes evident when debugging over USB is not connected. Reverse the order, and see if that helps.

@ Brett - I do subscribe to the .LineReceived event before the .Open. Is this correct or backwards?

@ Architect - I have the device connected to my USB port while debugging and “running on it’s own” - no change in the power.

Subscribe then open is BAD.

@ Brett - I switched it (subscribe AFTER open) and it behaves the same. I’m going to trim down the app to a smaller footprint (it decodes GPS, calculates distances, etc.).

@ Architect - Here is a trimmed version of the code (VB). It still runs in debug, but not in deployed.

Imports GT = Gadgeteer
Imports GTM = Gadgeteer.Modules
Imports System.Threading
Imports System.Text
Imports Microsoft.SPOT.Hardware
Imports Microsoft.VisualBasic
Imports Gadgeteer.Modules.GHIElectronics
Imports Gadgeteer.Interfaces.Serial

Partial Public Class Program

Dim gps As GT.Interfaces.Serial

Public Sub ProgramStarted()

        Dim objSocket As Gadgeteer.Socket
        objSocket = Gadgeteer.Socket.GetSocket(1, True, extender, "")
        gps = New Gadgeteer.Interfaces.Serial(objSocket, 19200, SerialParity.None, SerialStopBits.One, 8, HardwareFlowControl.NotRequired, extender)
        gps.LineReceivedEventDelimiter = Microsoft.VisualBasic.Constants.vbCrLf
        gps.AutoReadLineEnabled = True
        AddHandler gps.LineReceived, AddressOf GPS_handler 'moved here based on forum feedback

    Catch ex As Exception
    End Try

End Sub

Private Sub GPS_handler(ByVal sender As Gadgeteer.Interfaces.Serial, ByVal line As String)


    If line.Substring(0, 1) <> "$" Then Exit Sub
        led7r.TurnLightOn(1, True)
        display_HD44780.SetCursor(0, 0)
        display_HD44780.PrintString(line.Substring(0, 20))
    Catch ex As Exception
    End Try

End Sub

End Class

Using code tags will make your post more readable. This can be done in two ways:[ol]
Click the “101010” icon and paste your code between the

 tags or...
Select the code within your post and click the "101010" icon.[/ol]
(Generated by QuickReply)

@ DarrylN - This bug was supposed to be fixed in 4.2, but it looks like it is still there. Hand on I will have something for you shortly.

What bug? How can we fix?

The order of subscribing to data received event vs opening serial port. See more here:

Quick fix would be to ensure the order inside Gadgeteer’s Serial implementation, that wraps SerialPort. The proper fix (which was supposed to be in 4.2) is to make it work no matter what the order is inside NETMF SerialPort implementation.

So this is not fixed in 4.2!! This is unexpected!

@ Gus - i continued to remove code to see when/if it would deploy. The issue is in the Serial handler (when there is no serial port, the deployment works fine). Looking at MFDeploy, I am getting a buffer overflow message from the CLR when my app has the serial stuff and it is “deployed”. Would it be a reasonable guess that something is not getting cleared when the LineReceive event fires? That’s my noob unSWAG !

I know we’re in beta, and glitches are expected…but this product rocks, as do the clearly dedicated GHI team and the TinyCLR community!! Thanks.

We will check on our end and take the necessary steps to fix.

@ Gus - Would it be best not to subscribe at all using the gadgeteer wrapper? Perhaps use serial and poll it with a timer?

UPDATE: recompiled using a timer to poll the serial port and it deploys perfectly.