Globalsat BU353 S4 GPS Receiver showing garbled messages

I’m working on a project using a Globalsat BU353S4 GPS receiver but I’ve had garbled messages being returned when reading the data through the serial connection. What I’ve realised is that somehow the device has switched from NMEA to SiRF. I suspect this happens if you’ve been fiddling with the settings using python 🙂

You need swap your device from SiRF mode back to NMEA using the tool below.

Globalsat BU353S4

If you tested it with GPSInfo and you see garbage characters coming out, then, the device has possibly switched to SiRF mode. To switch it back to NMEA mode, please refer to the instructions below:

1. Download and install this software: http://www.usglobalsat.com/store/downloads/SiRFDemo387.zip
2. Run the Sirf Demo software.
3. Connect your device, choose the correct COM port, and select the 4800 baud rate.
4. Go to Action > Open Data Source.
5. Next, go to Action > Synchronize Protocol & baud rate.
6. Then, go to Action > Switch to NMEA Protocol.
7. In the pop-up window, select the 4800 baud rate under the Baud Rate and click Send.
8. Close the Sirf Demo software.
Note: Be sure and not to click on anything else in this software, as you can render your device unusable.

Now, try your GPS Receiver with the GPSInfo Utility (http://www.usglobalsat.com/store/downloads/GPSInfo.zip) to see if the problem persists.

I came across the solution here – http://usglobalsat.com/forum/index.php?topic=4348.0

AutoTDM – Automatically detect plugging in the thunderbolt cable and starting Target Display Mode

Each morning I’ve been hooking my MacBook Pro up to my iMac and having to start Target Display Mode (TDM). Every time I disconnected and reconnected the Thunderbolt cable I’d have to re-establish the Target Display Mode, along with when my MBP went to sleep. So, today I created a simple script to observe the network interfaces and detect when a Thunderbolt bridge was established and then fire off the CMD+F2 Target Display Mode shortcut on my iMac.

Check out the repo here – https://github.com/garbit/AutoTDM

I’ve also got a startup script in the project folder if you want to add it to your startup applications.

Android – Automating Testing and Store Listing Screenshots with Monkeyrunner

In this tutorial we’ll be talking about Monkeyrunner and automating tasks such as preparing screenshots for Google Play Store listings.

Monkeyrunner is a high level scripting language that is capable of automating tasks such as;

  • Installing/uninstalling apps
  • Taking screenshots and saving them to your local machine
  • Sending touch events i.e. performing gestures, pressing buttons, dragging and scrolling
  • Inputting text

There are three classes in the Monkeyrunner framework these are;

  1. MonkeyRunner – Connect to devices or emulators
  2. MonkeyDevice – Represents the device you are connected to. Allows you to perform touch events, apk installations, start activities
  3. MonkeyImage – Represents the raw image captured from the device and allows you to compare images for testing

In order to run a Monkeyrunner script you need to use the monkeyrunner compiler available in the android-sdk/tools directory, rather than python to run your python code.

<yourSDKfolder>/tools

In here you’ll have an executable moneyrunner which you’ll need to use to run your python scripts.

Go ahead and create a new python file, lets call it screenshots.py, place it anywhere you’d like. Let’s start by connecting to the device, installing your APK, taking a screenshot and saving the screenshot to our current directory.

Important
You’ll need to tell MonkeyRunner where your apk file is so that the screenshot.py can install the apk. You need to run your app on a device at least once for the IDE to generate you an apk file!

You can find your APK file in the following locations:
Eclipse
– projectFolder/yourNamespace/bin/your.apk
Android Studio
– projectFolder/yourNamespace/build/outputs/apk/your.apk

Create a py file and name it Screenshot.py – it should look like the following;

from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice
 
# Connects to the first device available through the adb tool
device = MonkeyRunner.waitForConnection()
 
# install the APK
device.installPackage('your.apk')
 
# declare your package name
package = 'com.your.application'
 
# declare your activity that you want to start
activity = 'com.your.application.MainActivity'
 
# prepare the whole package + activity string
activityToRun = package + '/' + activity
 
# start the activity above
device.startActivity(activityToRun)
 
# take a screenshot
screenshot = device.takeSnapshot()
 
# Writes the screenshot to a file
screenshot.writeToFile('screenshot1.png','png')

Place your APK file in the same directory as your py script, move into your androidsdk/tools directory and run your screenshot.py file in terminal.

cd into the <androidSDK>/tools
./monkeyrunner /your/path/to/screenshot.py

Now check out the <androidsdk>/tools folder and you should have a screenshot1.png.

MonkeyRunner Screenshot

You can also automate gestures on the phone as well as button presses, more on this in the next post.

Using the device object call press and pass in the keycode along with UP, DOWN or DOWN_AND_UP to simulate the gesture you want.

device.press('KEYCODE_MENU', MonkeyDevice.DOWN_AND_UP)

You can find the complete list of keycodes here – http://developer.android.com/reference/android/view/KeyEvent.html