Categories
GPS / GIS Programming

Firefox AJAX requests from different domain / site

Recently I’ve been writing a GPS mapping web page based on the OpenLayers JavaScript library that retrieves GPS data from the server via AJAX. For development convenience I was just storing the HTML file on my local drive for development and fetching the XML data from a different SQL/Server 2008 machine. This worked fine from IE but from FireFox the XMLHttpRequest I was getting a status of 0 (zero) returned and no data.

It turns out this is a security measure to avoid cross-site scripting which is quite sensible but not that convenient for testing, and in this application the authentication happens at a different level so cross-site scripting isn’t an issue. I found the solution is to add an HTTP header of Access-Control-Allow-Origin: * to the response. Of course you should consider the implications carefully outside of a test environment. As my code is written as a traditional ASP file this just consisted of adding the following line:

response.AddHeader “Access-Control-Allow-Origin”, “*”

Categories
Linux

Hammer Linux Board

Recently I’ve been doing some work with a TinCan Tools Hammer embedded Linux board. The hammer board is a neat little piece of hardware in a 40-pin DIP form factor, it looks good from a hardware point of view although unfortunately lacking a bit in the documentation area. I had some recent frustration getting MMC/SD card support to work which turned out to be a problem in the driver, their Linux programmer tracked it down and supplied the new mach-tct_hammer.c file required to fix things from a driver point of view.

Then I had some frustration because using buildroot as per the supplied configuration was giving me different results to the filesystem loaded onto the device at the factory, namely that it ended up being mounted read only. An attempt to remount the root partition read/write complained that /proc/mounts was missing which I was able to solve by adding the following lines to the device_table.txt file:

/proc        d    777    0     0    –    –    –    –    –
/proc/mounts    d    777    0     0    –    –    –    –    –
/proc/devices    d    777    0     0    –    –    –    –    –

Once these lines were included the root filesystem was mounted read/write by default. I then went on to add the following to device_table.txt:

/dev/mmcblk0     b     777     0    0     179     0     –     –     –
/dev/mmcblk0p1     b     777     0    0     179     1     –     –     –
/mnt/mmc    d    777    0    0    –    –    –    –    –

After which I was able to successfully mount a 4GB FAT32 formatted SD card using the command:

mount /dev/mmcblk0p1 /mnt/mmc

Categories
Programming SQL / Database

Application.FileSearch in MS Access 2007

I recently wrote a small application for someone using Microsoft Access 2003 and found the Application.FileSearch method of enumerating files is no longer available. The older “dir” function is still available so I replaced it with the following code to change the current drive and path and enumerate the files. Note this code will only work for local drive paths, not UNC style network paths.

Private Sub Form_Activate()

Dim i As Integer
Dim SearchPath As String
Dim Filename As String

SearchPath = GetPath() & "Backups"
ChDrive Mid$(SearchPath, 1, 2)
ChDir SearchPath
Filename = Dir("*.csv")
While Filename <> ""
  RestoreList.AddItem (Filename)
  Filename = Dir
Wend

End Sub
Categories
Linux

Today I was writing an application under Ubuntu Linux where I wanted the user to be able to click on a shell script to start running the main C++ application as a daemon in the background. I found a few example scripts using the nohup and disown commands but none of them seemed to work and my application would terminate as soon as the shell window closed. I found that it was necessary to include a sleep command between spawning the process and using the $! result for the disown command.

A few of the example scripts I found didn’t include a sleep and seemed to be parts of well tested and documented packages so maybe this requirement varies by Linux distros. The following is the latter segment of the bash shell script I wrote:

nohup $INSTALLDIR/myapp </dev/null >>$INSTALLDIR/myapp.log 2>&1 &
sleep 1
NEWPID=$!
disown $NEWPID
exit 0
Categories
Linux Programming

POSIX threads under arm-linux-g++

Today I was changing my TomTom datalogger to use threads for GPS reception and initially had some linking problems despite including pthread.h in the C++ source code and adding -lpthread to the linker options. The thing that threw me at first was pthread_create linked fine but I was getting linker undefined reference errors to other common POSIX threading calls such as pthread_exit and pthread_join.

At first I was worried that arm-linux-g++ didn’t support POSIX threads and was only providing an unimplemented stub routine for pthread_create that satisified the linker but didn’t work. It turned out however that POSIX threading is supported by GCC for the ARM but it doesn’t sit well with static linking of the libraries. I’d only used static linking for initial convenience when I wasn’t sure what libraries would be required, once the project was converted to dynamic linking of the LGPL libraries required by the project everything worked fine.

Categories
GPS / GIS

TomTom V3 GPS feed finally resolved

After believing I had the problem solved with the TomTom GPS feed after some quick bench testing I was looking forward to gathering some good test data during a business trip to Victoria that involved quite a bit of driving around. Unfortunately the problem cropped back up during mobile testing and I didn’t have time to troubleshoot before leaving. Presumably the extra processing the TomTom navigator application was doing while moving and calculating routes caused the timing of everything to alter a little and rendered the data I collected uselesss.

After further investigation today despite trying a few different techniques the C++ stream failbits and eof bit I was relying on don’t seem to get set correctly for the GPS feed. I’m not sure yet if this by design, a bug in the GCC ARM C++ standard libraries or a problem with the TomTom GPS driver. Once I knew the underlying problem it was easy to change the application logic to cope with the blocking that not having the eof indicator caused. I’ve now confirmed during further driving tests I can collect 100% of data to progress the KML and HTML data generation. Soon I will change my GPS C++ library to use threads rather than relying on the eof bit, a side-effect of my current workaround is that the signals I use to shut down the application gracefully won’t be received in a timely manner.

Categories
Operating systems

VMWare shared serial ports with Windows XP

Recently the serial communications ports on a VMWare machine I had setup for embedded development stopped working. I believe what triggered the problem was booting the VM while another VM had the same physical serial ports locked and it appeared to get the XP device stack into an odd state. I found that by deleting the serial ports under hardware manager and performing a reboot it cleared the problem.

Categories
Operating systems

Windows domain slow login

Today I was creating a new VMWare virtual machine to install some embedded development tools I need for an upcoming project but don’t use often enough to have cluterring my main machine. The first login after adding the machine to the Windows domain took approximately 20 minutes. It reminded me I’d had the same problem a few years ago and the problem can occur when the machine is set to use an Internet DNS server rather than the DNS server for the local domain. Adding the local domain DNS server as the first priority DNS server for the network adapter corrected the problem.

Categories
GPS / GIS

TomTom One V3 GPS Pause Revisited

After being side-tracked onto another project I got back to the TomTom datalogger application and believe I’ve solved the problem with intermittent pauses in the GPS output from /var/run/gpsfeed. The problem ended up being easy to repeat on the bench and in fact I could see the same pauses doing a cat /var/run/gpsfeed from the serial console but only when my application was running in the background. It only occured when my main loop was set to check for new input every 200mS, when I put it up to one second everything started working smoothly.

The TomTom is set to output a GPS fix approximately every 800mS so 200mS seemed like a fairly appropriate value to keep the buffers flushed and everything running along smoothly, but instead it appears the driver may have a problem if the buffer gets emptied too often. I’m using C++ streams so just have a fairly typical while stream.good style loop to process any new data received on a character basis and go ahead and process the data when a new $GPRMC / $GPGGA pair has been received. It will need some field testing but fingers crossed problem is now solved.

Categories
GPS / GIS Hardware

TomTom One V3 GPS Feed

Doing some testing on a TomTom datalogger application I’m writing I’m finding some data gaps in the NMEA GPS output both from /var/run/gpsfeed and /var/run/gpspipe. At first I suspected the feed may not be sending out NMEA data during a loss of coverage, however recently observed the TomTom tracking OK during a period the problem was occuring. It is possibly because I’m attempting to log all data so that I can post-process the data for reporting and KML generation. To assist hearing when the data feed stops without taking my eyes of the road I’ve attached a piezo buzzer and diode to a DB-9 connector that seems to give an audible but not too annoying sound at 115200 bps.

tomtom3