Use a GPS Tracker in a web application

8535
8
02-11-2015 07:56 AM
El_BoukfaouiReda
New Contributor II

Dear,

I am using this GPS tracker(http://kenshinjeff.jp/wp-content/uploads/2011/09/User-manual-TK102-2.pdf ).

I want now to get real time movement data locations on top of my basemap service using the ArcGIS JS API and without getting to use GeoEvent processor Extension

I have done my research and I found that there is a possibility to use this library(fvdm/nodejs-tk102 · GitHub‌)

Has anybody got any experience setting this up before?

I need more details and guidance please.

Reply
0 Kudos
8 Replies
HaroldBostic
Occasional Contributor II

that's a pretty loaded question and will require some thought based on your responses.  Do you already have Node up and running?  What's your productions environment, windows, linux?

Reply
0 Kudos
El_BoukfaouiReda
New Contributor II

I know it is a pretty important question as well to me right now.

I don't have a Node up on running! I am very new to this processing. For me it is almost in R&D.

My production environment is Windows, but I still can work with a Linux Desktop through a virtual partition within my current machine hopefully.

Do you think the tutorial is a good resource to follow even if the GPS Tracker is not the same?

I recognize though some processes which are mutual to my GPS Tracker TK-102 which is a Siemens and not a Xexun !

Reply
0 Kudos
AlexBostic
New Contributor II

I'm not a GPS tracker guy, so take that I don't think the differences will be major with a grain of salt.  To get started with Node in a windows environment, I would recommend downloading Chocolatey Gallery and using that as you windows package manager.  then from your command line you can do this

C:\> choco install nodejs.install

I suppose you'll need to have your device connected to your machine so that it can communicate to your open port.

If connecting your machine to your device is not an option, I would suggest using OpenShift to get things up and going on the open web for free.  Sign up for an account and follow these instructions

OpenShift Online for Windows | OpenShift Developers

Once you get Node setup on your machine or OpenShift, come back and we'll go to the next step.

If you need help getting set up, let me know

El_BoukfaouiReda
New Contributor II

There is no need to install the NodeJS-TK102 then, I guess.

I have now successfully installed the NODEJS :

Nodejs.png

What is the next step please? Connect the GPS Tracker to the NodeJS?

Reply
0 Kudos
AlexBostic
New Contributor II

I would still install NodeJS-TK102.  From your command line navigate to the directory you want to operate from (you may have to create it)  For prototypes, I put things in my c>projects directory, so I would create a folder under C:\projects\ called tk102, then I create a folder under that called server.  So mine would be C:\projects\tk102\server

once you are in that directory run this command taken from the github repo you posted npm install tk102

That will install the NodeJS-TK102 library for you.

next, you'll want to prepare your device for transponding your coords, do you have instructions on that, or the manual you can link to?

after that you would create a node project, pull in the library and interact with it's api.  I can post about that later

Reply
0 Kudos
El_BoukfaouiReda
New Contributor II

I have installed NODEJS-TK102 successfully.

I have set-up one point coordinate and many using auto tracking and following the manual instructions.

I am ready for the next step which is creating a node project. I have also connected my GPS Tracker to my laptop. Can you give me more details about how to interact with it now using the Node and collect the required coordinates?

Reply
0 Kudos
AlexBostic
New Contributor II

I recommend that you get an IDE if you don't have one.  I recommend WebStorm, but it's only free for a month, then you'll have to pay.  Some alternatives are Visual Studio, Aptana, search this forum for others

next you'll go on your command line and navigate to your project directory, mine is C:\projects\tk106\server\src

the next step will walk you through creating your package.json file, it will ask you want you want to call your application file, it defaults to index.js, I call mine server.js, so anywhere you see server.js below, replace it with the name you give your file

type 'npm init'

This will help you create your package.json file which is the package manager for your file.  It will ask you a few questions, then create the file.

I believe you said you installed tk102 already, if so, skip this step:

     Once the file is created, type 'npm install tk102 --save'

     the --save option will be sure to add the dependency into your package.json file

My personal preference is to install nodemon as well, so that my server auto restarts as I make changes

I do that by typing 'npm install nodemon --save-dev'

This will add nodeman as a dependency to your development environment inside your package.json file

if you installed nodemon do the following:

    Now open your package.json file

    remove the line "main": "server.js",

    add this line in the scripts object above test

    "start": "NODE_ENV=local ./node_modules/.bin/nodemon server.js",

Depending on what you stated your default node file would be, create that file.  I created a file named server.js

Open your server.js file and follow the example from the tk106 repo:

type the following:

------------------------------------------------------------------------------------

'use strict';

var server = require('tk102');

server.createServer({

    port: 1337

});

server.on( 'listening', function( listen ) {

    console.log('listening on port: ' + listen.port);

});

server.on( 'data', function( raw ) {

    console.log( 'Incoming data: '+ raw )

});

server.on( 'track', function( gps ) {

    console.log( gps )

});

------------------------------------------------------------------------------------

at this point, you should be able connect your device to your server.  if things don't work, then you'll have to dig into the tk102 server source code and update it. it's located in node_modules\tk102\tk102.js

if you attach the manual, I may be able to help further as any errors will probably be in the parser.  Hopefully you get something in the console.log( 'Incoming data: '+ raw ) statement

let me know how that goes.

sometimes you may have to stop node from running, in that case I run this on my mac

lsof -n -i :1337

COMMAND  PID       USER   FD   TYPE             DEVICE SIZE/OFF NODE NAME

node    1887 alexbostic   14u  IPv4 0x7e6cfdb8acf18bf5      0t0  TCP *:hbci (LISTEN)

sudo kill -9 1887

lsof -n -i :1337

npm start

Reply
0 Kudos
El_BoukfaouiReda
New Contributor II

I own the GPS tracker USB cable. So, when I get to connect it with my computer, it doesn't really react to it.

How do I interact with my computer then knowing that I am planning for a real-time tracking solution later on?

I am expecting the following scenario as I use my tracker:

Receive signals from my GPS tracker while outdoors when requesting my position or proceed for a real-time tracking using the device, something like:

https://www.traccar.org

Please find herein below the URL to the GPS tracker guide:

http://kenshinjeff.jp/wp-content/uploads/2011/09/User-manual-TK102-2.pdf

And Thank you again ! You have been so helpful till now !

Reply
0 Kudos