I gave this a shot today, and it somewhat works. I had to make my own modifications, here's what I did:
first, at the terminal, you have to setup the USB for data querying at a given baud rate:
sudo stty /dev/ttyUSB0 ispeed 4800
then in freemat, simply:
fid = fopen('/dev/ttyUSB0','r+');
n = fgetline(fid);
You can run this as a loop with a wait(1) feature to make sure you don't catch up with the end of the file (the file continues to grow each second as the GPS adds a query line), or you could simply let it run with a wait command if you reach the end of the file (a simple if feof(fid) wait(1) statement ought to do). Note: Garmin Etrex GPS, text output mode. Every other line will be blank, so usually my code looks something like this:
for i = 1:1000
fid = fopen('/dev/ttyUSB0','r+'); % opens /dev/ttyUSB0 for data query
n = fgetline(fid); % gets blank line
m = fgetline(fid); % gets data line
n and m will be strings, with the following format (I've already written a script to decode this into useful data, I'll upload it when I get to my work computer tomorrow):
<<note: borrowed from
http://www.zerofusion.ca/moike/cabling.html>>
Simple Text Output Format:
The simple text (ASCII) output contains time, position, and velocity data in
the fixed width fields (not delimited) defined in the following table:
FIELD DESCRIPTION: WIDTH: NOTES:
----------------------- ------- ------------------------
Sentence start 1 Always '@'
----------------------- ------- ------------------------
/Year 2 Last two digits of UTC year
| ----------------------- ------- ------------------------
| Month 2 UTC month, "01".."12"
T | ----------------------- ------- ------------------------
i | Day 2 UTC day of month, "01".."31"
m | ----------------------- ------- ------------------------
e | Hour 2 UTC hour, "00".."23"
| ----------------------- ------- ------------------------
| Minute 2 UTC minute, "00".."59"
| ----------------------- ------- ------------------------
\Second 2 UTC second, "00".."59"
----------------------- ------- ------------------------
/Latitude hemisphere 1 'N' or 'S'
| ----------------------- ------- ------------------------
| Latitude position 7 WGS84 ddmmmmm, with an implied
| decimal after the 4th digit
| ----------------------- ------- ------------------------
| Longitude hemishpere 1 'E' or 'W'
| ----------------------- ------- ------------------------
| Longitude position 8 WGS84 dddmmmmm with an implied
P | decimal after the 5th digit
o | ----------------------- ------- ------------------------
s | Position status 1 'd' if current 2D differential GPS position
i | 'D' if current 3D differential GPS position
t | 'g' if current 2D GPS position
i | 'G' if current 3D GPS position
o | 'S' if simulated position
n | '_' if invalid position
| ----------------------- ------- ------------------------
| Horizontal posn error 3 EPH in meters
| ----------------------- ------- ------------------------
| Altitude sign 1 '+' or '-'
| ----------------------- ------- ------------------------
| Altitude 5 Height above or below mean
\ sea level in meters
----------------------- ------- ------------------------
/East/West velocity 1 'E' or 'W'
| direction
| ----------------------- ------- ------------------------
| East/West velocity 4 Meters per second in tenths,
| magnitude ("1234" = 123.4 m/s)
V | ----------------------- ------- ------------------------
e | North/South velocity 1 'N' or 'S'
l | direction
o | ----------------------- ------- ------------------------
c | North/South velocity 4 Meters per second in tenths,
i | magnitude ("1234" = 123.4 m/s)
t | ----------------------- ------- ------------------------
y | Vertical velocity 1 'U' (up) or 'D' (down)
| direction
| ----------------------- ------- ------------------------
| Vertical velocity 4 Meters per second in hundredths,
\ magnitude ("1234" = 12.34 m/s)
----------------------- ------- ------------------------
Sentence end 2 Carriage return, '0x0D', and
line feed, '0x0A'
----------------------- ------- ------------------------
If a numeric value does not fill its entire field width, the field is padded
with leading '0's (eg. an altitude of 50 meters above MSL will be output as
"+00050").
Any or all of the data in the text sentence (except for the sentence start
and sentence end fields) may be replaced with underscores to indicate
invalid data.