Main Site Documentation

Debug help


#1

Hi:
I am trying to understand why I get an error when using the bluetooth module. This error is handled, but I still want to understand what is happening.
This is with a FEZ_Raptor, and the Bluetooth 1.1 module, visual studio 2012 and VB.
The immediate window shows:
Bluetooth status OK

+BTSTATE:

#### Exception System.IndexOutOfRangeException - 0xa9000000 (6) ####
#### Message: 
#### System.Convert::ToInt64 [IP: 002e] ####
#### System.Convert::ToInt32 [IP: 0011] ####
#### System.Int32::Parse [IP: 000b] ####
#### Gadgeteer.Modules.GHIElectronics.Bluetooth::runReaderThread [IP: 0062] ####

Then I look at the stack trace, I see that the error is in > GTM.GHIElectronics.Bluetooth.dll!Gadgeteer.Modules.GHIElectronics.Bluetooth.runReaderThread() Line 175 + 0x8b bytes C#

Clicking on this line to view the code brings the message "Bluetooth_42.cs not found"
I have done a search for this module in my PC for this module but no luck.

At this point I have bluetooth running, but I would like to understand how to better use the debugger to avoid these handled errors if possible as I imagine that handling errors slows things down.

Thanks


#2

i never saw this error using the bluetooth module.
you can find the sorce code on codeplex:

maybe it help…

another driver you can find at codeshare

https://www.ghielectronics.com/community/codeshare/entry/763


#3

Thanks Daniel
Now I understand how to get debugging information by downloading the source and pointing the compiler at it.
The error is shown below. After the error I printed the variables involved. You can see that last=-1 thus it does not work to parse the substring of response.

The error is in runReaderThread of Bluetooth_42.cs

+BTSTATE:4

#### Exception System.ArgumentOutOfRangeException - CLR_E_OUT_OF_RANGE (6) ####
#### Message: 
#### System.String::Substring [IP: 0000] ####
#### Gadgeteer.Modules.GHIElectronics.Bluetooth::runReaderThread [IP: 005c] ####

?response
"\r\n+BTSTATE:4\r"
?first
11
?last
-1

I see your reference to RoSchmi’s bluetooth module, and I understand that this handles high data rates better. My application is for very low data rates, and I am not sure how to substitute the module when working in VB.net.

Thanks


#4

first you have to compile the c# project. Then you can reference the bin / .dll
now you can use it like any other objekt


#5

another way after compile th new driver is to replace the original…

have a look on

https://www.ghielectronics.com/docs/122/gadgeteer-driver-modification


#6

Hi Daniel:
I was able to get it working following your suggestions - Thanks!
I have not seen any seen the same error as with the other GHI module. Thanks RoSchmi - it seems to work well and seems stable, as far as I have tested.

I am able to maintain a robust connection to my Android phone and a free app called BTClient. I can connect and the connection will persist. My application sends a time string every second, which is shown on the phone’s screen. There is a keypad on the phone and I can enter characters which are sent and show on my T43 display attached to the Raptor.

I also have the 32Feet (http://32feet.codeplex.com/) example working.

Thanks for your help


#7

@ rockybooth -
Hi rockybooth, I’m glad to hear that it works for you.
It would be great if you could post your adapation to visual basic here. If you agree I could include the VB adaptation in the CodeShare entry of the driver.
Cheers
Roland


#8

I plan to post my VB version of bluetooth communications using RoSchmi’s code, buy I have run into a problem - as I want to implement both host and client modes (so I can communicate bidirectionally between two Raptor’s) - I cannot determine how to send data from a Host. There does not seem to be a SendLine routine associated with the HostMode as there is with the ClientMode. If I try to define both modes, I get an error “Cannot use both Client and Host modes for Bluetooth module”.

What is the best approach?


#9

you can copy the send function from the client to the host class


#10

@ VB-Daniel - Thanks, Bluetooth.serialport.writeline(s) works!


#11

@ rockybooth - Great. As far as I know nobody yet posted an application where a Gadgeteer device used the bluetooth module in host mode. How did you manage the pairing?
In the hope that it helps I post a link to a application where two arduinos communicated over the identical Bluetooth module
-http://www.seeedstudio.com/wiki/index.php?title=Bluetooth_Bee#Connecting_to_Arduino_with_XBee_Shield
Cheers Roland


#12

@ RoSchmi - I have not noticed jet that no one has used the host mode. I writing and testing my driver in the moment and only use the hoste mode to communicate with my win8 application.
Will share the driver in a few days…

Daniel


#13

@ VB-Daniel -
Great, looking forward to see ist.


#14

@ RoSchmi, @ VB-Daniel, have either of your been able to connect to iOS devices, like the iPAD or iPhone? While I have been successful with RoSchmi’s bluetooth code for Android and PC connections, I have not had luck at all with iOS devices.


#15

No, iOS does not support SPP and afaik there are no means to use RFCOMM. You can use Justin’s Bluetooth 4.0 module


#16

RoSchmi: I could not duplicate being able to work in host mode. It may be that I had connected in client mode to the PC and exchanged PIN at the PC OS level, then switched to host mode on the Raptor while still paired (just a guess) - of course it was late at night…
I plan on setting up a second Raptor and work on the host mode in a few days. I will try to follow the Arduino link you sent.