help about WIFI raspberry

General project help for Adafruit customers

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
ddcedric
 
Posts: 8
Joined: Mon Jan 28, 2013 3:09 pm

help about WIFI raspberry

Post by ddcedric »

Hi, I need your help, so I'll explain my problem :arrow:
I have 2 raspberry PI, one is used as a GPS (EM-406A) and the other raspberry is set as a server

So I would like to send the frame NMEA of GPS by WI-FI in raspberry server
But I do not know how

thank you :)

User avatar
adafruit_support_mike
 
Posts: 67446
Joined: Thu Feb 11, 2010 2:51 pm

Re: help about WIFI raspberry

Post by adafruit_support_mike »

The easiest way to do it would be through TCP/IP services.

With enough experience you can write your own server program, assign it to a port on the second RasPi, and configure the 'inetd' daemon to launch you program every time a request for that port comes in. That does take a fair amount of background knowledge though.

An easier way to do the same general thing is to run a webserver on the second RasPi and have the first one (with the GPS) make HTTP requests using the 'httplib' module (renamed to 'http.client' in Python 3). The general subject you want is "CGI scripting under Apache", and it's pretty simple once you know the basic tools.

'CGI' stands for 'Common Gateway Interface', and describes how the webserver passes information to the script that will process it. There's a set of standard variables the script can read, like REQUEST_URI and QUERY_STRING. Wikipedia has a decent description of it: http://en.wikipedia.org/wiki/Common_Gateway_Interface

'Apache' is the webserver on almost all Linux machines, and definitely the one you'll use on a RasPi. There's a good set of instructions on getting it running here: http://elinux.org/RPi_Apache2 .

ddcedric
 
Posts: 8
Joined: Mon Jan 28, 2013 3:09 pm

Re: help about WIFI raspberry

Post by ddcedric »

I understand, but I'm not very good programmer, I find this:
http://www.stripydog.com/kplex/
I think I could use it, but I do not see how

User avatar
adafruit_support_mike
 
Posts: 67446
Joined: Thu Feb 11, 2010 2:51 pm

Re: help about WIFI raspberry

Post by adafruit_support_mike »

ddcedric wrote:I understand, but I'm not very good programmer, I find this:
http://www.stripydog.com/kplex/
I think I could use it, but I do not see how
You'd probably have a harder time learning to use that than you would learning to do some simple CGI programming. I'm not sure it's really appropriate to what you're trying to do, either. It seems to be a tool that collects data from any number of different sources on a single computer, but doesn't do much about getting information from one computer to another.

I don't think there's any simple 'here, use this' solution for what you're trying to do, so some amount of programming will probably be necessary. Almost any programming language you choose will have a library to handle web requests, so all you need to do on the 'sender' side is plug the correct values into a 'request this page with this data' function. On the 'listener' side, you'll just need something that reads the data and sends it wherever you want it to go.

ddcedric
 
Posts: 8
Joined: Mon Jan 28, 2013 3:09 pm

Re: help about WIFI raspberry

Post by ddcedric »

could you help me, I do not know how to do this :?:

But I recall that there are two raspberry, 1 is the server, and another is to connect the gps

User avatar
static
 
Posts: 188
Joined: Thu Dec 23, 2010 6:21 pm

Re: help about WIFI raspberry

Post by static »

This is kind of a stretch. You're asking the community to write your code for you.
It's one thing to ask for pointers or to show your work and explain the problem you're having. It's another to say "Here's my idea, write the code for it".

I'm working on a similar project using Raspberry Pi's and I2C sensor devices (different than interfacing with a GPS). So far, it's a couple of hundred lines of code, dozens of hours, and many set-backs. I've learned a tremendous amount, and I pretty much started from scratch (I did a little work with Arduino's before this).

Eventually I'd like to build a GPS in to my project, but I don't have the GPS components. I wouldn't be able to help you that much.

I will tell you this: Python is an incredibly easy programming language to pick up and learn. It's free. There are an insane number of already built libraries. There is a ton of free information about it and some of the textbooks are definitely worth the money.

ddcedric
 
Posts: 8
Joined: Mon Jan 28, 2013 3:09 pm

Re: help about WIFI raspberry

Post by ddcedric »

I know slightly coded in python, I asked the 'main steps' of my code.

ddcedric
 
Posts: 8
Joined: Mon Jan 28, 2013 3:09 pm

Re: help about WIFI raspberry

Post by ddcedric »

I know slightly coded in python, I asked the 'main steps' of my code.

User avatar
adafruit_support_mike
 
Posts: 67446
Joined: Thu Feb 11, 2010 2:51 pm

Re: help about WIFI raspberry

Post by adafruit_support_mike »

The main steps would be..

On the receiver side:

- Get a copy of the Apache webserver running on the machine you want to receive the data
- Create a script that knows how to read data from a POST request (the same thing web forms use)
- Save that script where the webserver can see it, and will execute that script when clients POST to the script's URL


On the sender side:

- Get the GPS output
- Open a POST connection to the receiver, with the URL for the script
- Send the GPS output as data for the POST request

ddcedric
 
Posts: 8
Joined: Mon Jan 28, 2013 3:09 pm

Re: help about WIFI raspberry

Post by ddcedric »

thx very much :)

laika
 
Posts: 1
Joined: Sun May 12, 2013 7:27 pm

Re: help about WIFI raspberry

Post by laika »

adafruit_support_mike wrote:
ddcedric wrote:I understand, but I'm not very good programmer, I find this:
http://www.stripydog.com/kplex/
I think I could use it, but I do not see how
You'd probably have a harder time learning to use that than you would learning to do some simple CGI programming. I'm not sure it's really appropriate to what you're trying to do, either. It seems to be a tool that collects data from any number of different sources on a single computer, but doesn't do much about getting information from one computer to another.
On the contrary. It's exactly what the OP wants. Run two copies: one on each machine. On the pi the GPS is connected to (let's call this machine "gpshost") you ask kplex to read from the GPS (let's assume it's like my adafruit ultimate gps running at 9600 baud attached to /dev/AMA0) and create a tcp server (will default to listening on port 10110 on all interfaces).Config looks like this:

Code: Select all

[serial]
filename=/dev/ttyAMA0
direction=in
baud=9600
[tcp]
mode=server
direction=out
On the other machine tell it to connect to the tcp server running on "gpshost" (you can use an ipv4 or ipv6 address if there's no dns or hosts entry for the machine with the gps). You could configure it with a config file and make the output available over a pty or another tcp server, or you could run it from the command line and pipe the output into another program. Or both. Say we want to feed the nmea sentences into a program called "myprog" we could run:
kplex tcp:address=gpshost file:direction=out | myprog

Yes there's a lot of stuff in the instructions to wade through but it saves doing the network programming yourself

Locked
Please be positive and constructive with your questions and comments.

Return to “General Project help”