How to print GPS location to stdout (Ubuntu 16.04 / 18.04)? - gps

I'm a complete newbie with GPS devices on Linux.
I have a GlobalSat G-STAR IV USB device and I would just like to get the GPS location (lat, long) printed to stdout. How can I achieve that? I'm reading about gpsd, but not sure how to get the actual location. The documentation seems old.
Any common tools etc for this?
It seems that with
$ sudo stty -F /dev/ttyUSB0 4800
$ sudo cat /dev/ttyUSB0
I can read some NMEA(?) data from the device:
$GPGGA,113935.199,,,,,0,00,,,M,0.0,M,,0000*5B
$GPGSA,A,1,,,,,,,,,,,,,,,*1E
$GPRMC,113935.199,V,,,,,,,100918,,,N*41
$GPGGA,113936.186,,,,,0,00,,,M,0.0,M,,0000*56
$GPGSA,A,1,,,,,,,,,,,,,,,*1E
$GPRMC,113936.186,V,,,,,,,100918,,,N*4C
$GPGGA,113937.185,,,,,0,00,,,M,0.0,M,,0000*54
$GPGSA,A,1,,,,,,,,,,,,,,,*1E
$GPRMC,113937.185,V,,,,,,,100918,,,N*4E
$GPGGA,113938.200,,,,,0,00,,,M,0.0,M,,0000*55
$GPGSA,A,1,,,,,,,,,,,,,,,*1E
I still don't see $GPGLL that should contain the location..?
Edit: I also get this:
$ sudo gpsd /dev/ttyUSB0 -N
gpsd:ERROR: can't bind to IPv4 port gpsd, Address already in use
gpsd:ERROR: maybe gpsd is already running!
gpsd:ERROR: can't bind to IPv6 port gpsd, Address already in use
gpsd:ERROR: maybe gpsd is already running!
I have killed all gpsd instances and deleted the socket, but still getting that..

The output you posted from sudo cat /dev/ttyUSB0 is what you would expect for a GPS module, which does not (yet) have a fix, i.e. it does not have enough information to calculate its current position (+other information).
The only information provided by the messages is the current time of day, 11h39m35s, etc. Out of the messages you receive from your GPS module, not only the $GPGLL message can tell you about your location, but also the $GPGGA and $GPRMC messages that you do receive. If your module had a fix, you would not see several commas in a row but actual values in between.
More details about the format of the different messages can be found in this overview.
What is the likely root cause for the missing GPS fix (assuming your hardware + antenna are fine)?
You have just started using this module fresh from the factory and it needs some time to get ahold of its coordinates. The time to first fix for such a brand new device can be up to 15 minutes.
The GPS signal strength is not strong enough at the location of your module.
Therefore my advice:
Make sure that at your location, the GPS signal from the satellites is strong enough. Ideally by moving outdoors.
When your module has never had a fix before, give your module some time. Wait for up to 20 minutes.
GPSD:
GPSD, if installed, is normally started automatically, when you plug in a GPS module. You can check the current status with
systemctl status gpsd.service
systemctl status gpsd.socket
If active, the gpsd deamon reads out the GPS-data coming via the serial interface and provides it to other applications via a socket on a specific port (default: port 2947). In that case the serial port is not accessible anymore by serial monitors.

Steps to make this device work were:
# Switch the device to NMEA mode
sudo gpsctl -f -n /dev/ttyUSB0
# Set baudrate to 4800
sudo stty -F /dev/ttyUSB0 4800
# Start gpsd
gpsd -S 4000 /dev/ttyUSB0
Now create a TCP/IP socket connection to localhost:4000 and say ?WATCH={"enable":true,"json":true}; or use libgps etc:
http://www.catb.org/gpsd/client-howto.html

Related

Stop High Sierra's httpd/apache and use Homebrews?

I want to use Homebrew's version of Apache on my Mac so I can start/stop it as I please, so I've been trying all afternoon to stop and unload several httpd processes that are run by user _www on macOS 10.13.3 High Sierra without any luck.
See the screenshot attached, there are 6 httpd processes run by _www and the single process run under root (Homebrew service)
I've tried
sudo launchctl unload -w /System/Library/LaunchDaemons/org.apache.httpd.plist
which gives me an error:
/System/Library/LaunchDaemons/org.apache.httpd.plist: Could not find specified service
I've also tried tracking the process starting them down, switching user to _www (a no no) so I can see where it's being started and so far I'm having no luck.
I want to kill them all, and have them stay dead as right now they're conflicting with the server I'm actually trying to run. Anyone cleverer than me out there that knows how to kill this literal http demon?
https://stackoverflow.com/a/20439859/996338
Try this:
sudo launchctl unload -w /System/Library/LaunchDaemons/org.apache.httpd.plist
This will stop a running instance of Apache, and record that it should not be restarted. It records your preference in /private/var/db/launchd.db/com.apple.launchd/overrides.plist.
For a single session (meaning, between reboots), you can use sudo apachectl stop.

Raspberry Pi 2 GPSD Not Running

I am following this tutorial to hook up Adafruit's Ultimate GPS Breakout to my Raspberry Pi 2. I have carefully read each step.
When I run gpsmon /dev/ttyUSB0, it displays expected output with my location, speed, etc. When I run cgps -s, however, I get this message cgps: no gpsd running or network error: -4, can't create socket.
The really weird thing is that the GPSD seems to be failing. Here is me trying to start it:
pi#raspberrypi:~$ sudo service gpsd status
[FAIL] gpsd is not running ... failed!
pi#raspberrypi:~$ sudo service gpsd restart
[ ok ] Restarting GPS (Global Positioning System) daemon: gpsd.
pi#raspberrypi:~$ sudo service gpsd status
[FAIL] gpsd is not running ... failed!
pi#raspberrypi:~$ sudo service gpsd start
pi#raspberrypi:~$ sudo service gpsd status
[FAIL] gpsd is not running ... failed!
So, it is apparent that cgps is failing because GPSD is not starter. Any suggestions to get GPSD working?
EDIT
When I run sudo gpsd -N -D3 -F /var/run/gpsd.sock, I get this output:
gpsd:INFO: launching (Version 3.6)
gpsd:ERROR: can't bind to IPv4 port gpsd, Cannot assign requested address
gpsd:ERROR: can't create IPv6 socket
gpsd:DATA: command sockets creation failed, netlib errors -1, -1
Late answer. However I just bumped into this problem and found that my /etc/network/interfaces didn't exist. Thusly there was no loopback interface present. If interfaces doesn't exist, try creating it by running sudo nano /etc/network/interfaces and add:
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet dhcp
(Or as it suits your setup.)
Then run ifup -a and check if there's a new interface by running ifconfig. It should be somewhat like:
eth0 Link encap:Ethernet HWaddr b8:27:eb:16:bc:52
[...]
lo Link encap:Local Loopback
[...]
Hope it works for others as well.
For unrelated reasons, I reimaged my Pi, and the gps module is now working as expected. I don't know what was wrong last time, but it is working now.

GPSD not getting a good fix

I have a GPS module connected to a Raspberry Pi via USB.
For some reason I can't seem to get a fix using:
cgps
it doesn't seem to get a fix and terminates.
I've also tried:
sudo killall gpsd
sudo gpsd /dev/ttyUSB0 -F /var/run/gpsd.sock
and then tried cgps again, but that doesn't seem to work either.
I even tried:
sudo nano /etc/default/gpsd
and changed the line:
GPSD_OPTIONS=""
to:
GPSD_OPTIONS="/dev/ttyACM0"
which apparently worked for others around the web, but after a reboot, that didn't work either.
But for some reason when I do:
gpsmon /dev/ttyUSB0
I get a full readout of data; lat, lon, Sats, altitude, ext.
Is there a way to output gpsmon /dev/ttyUSB0 sentences to a text file?
Also, why can't I obtain a fix using cgps or something similar?
gpsd is a beautiful application to simplify gps use, but it can be a little confusing.
If you're using a Rasbian, or some apt based package system it is best to configure it with sudo dpkg-reconfigure gpsd to avoid complications (tyqos), but isn't necessary. We have preferences for, but you may not,
autostart,
-n Don't wait for a client
-G to listen on all addresses,
-b Broken-device-safety mode, and
autofind
The resultant configuration file looks like
# Default settings for gpsd.
# Please do not edit this file directly - use `dpkg-reconfigure gpsd' to
# change the options.
START_DAEMON="true"
GPSD_OPTIONS="-n -G -b"
DEVICES=""
USBAUTO="true"
GPSD_SOCKET="/var/run/gpsd.sock"
The primary stumbling block with this approach while gpsd is running in this fashion is it will grab the gps before you can. Attempts to independently and directly access the device /dev/whatever will fail as busy.
If you wish to go that route, for whatever reason, before doing anything else, make sure gpsd is not running.
sudo killall gpsd
and remove any sockets gpsd might have left behind,
sudo rm /var/run/gpsd.sock
Check the location of your gps by attaching it and tracking where it went with dmesg | tail. It will look something like
[67338.935645] usb 1-1.2: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[67338.935650] usb 1-1.2: Product: USB-Serial Controller
[67338.935653] usb 1-1.2: Manufacturer: Prolific Technology Inc.
[67338.936154] pl2303 1-1.2:1.0: pl2303 converter detected
[67338.937953] usb 1-1.2: pl2303 converter now attached to ttyUSB1
[67339.806917] pl2303 ttyUSB1: usb_serial_generic_read_bulk_callback - urb stopped: -32
[67339.807306] pl2303 ttyUSB1: usb_serial_generic_read_bulk_callback - urb stopped: -32
[67340.018016] pps_ldisc: PPS line discipline registered
[67340.018321] pps pps0: new PPS source usbserial1
[67340.018330] pps pps0: source "/dev/ttyUSB1" added
Then you can check for output with sudo cat /dev/ttyUSB1...or whatever, but you could do that with gpsd running. (You can also pump this into a text file sudo cat /dev/ttyUSB1 > gps_dump.txt, or your gpsmon /dev/ttyUSB0 >gps_dump.txt, but there are more elegant solutions.)
The flip side of the confusion is no gps output from the gpsd because it isn't running or configured 'properly'. (either turned off, not started, or pointing to the wrong device). A few application will tell you it's not running, many just sit in silence without any data. I know of none that will tell you gpsd has been manually set to the wrong device.
If you have killed gpsd, or do not have it automagically start, ensure that it is running with sudo /etc/init.d/gpsd restart
Unless you're doing something odd with odd hardware most cases will spit back data with gpsd in these settings, sparing the need for diagnostic settings.
However, bear in mind cgps will timeout if there is no fix. Check your skyview, and Time To First Fix. xgps, on the other hand, is more resilient for failures and provides clues for the absence, or quality of data. If you have an X server, xgps is actually my preferred test for "is it working". If you don't, but have your Pi on a network (xgps 192.168.0.6, or whatever, because the other machine has gpsd-client installed). Another option is to ssh -X user#192.168.0.6 and then execute xgps)
Telneting into gpsd, while interesting, is another tier diagnostic, as are others.
And finally, a shameless plug for a Python client for gpsd (gps3.py) as means to access the data from a gpsd. It still is alpha, but it doesn't import historical cruft.
You may be binding to the wrong serial. You discover the serial for your GPS device by navigating to the folder below without the device plugged in, then refreshing with the device plugged in.
cd /dev/
ls
My device is called "ttyACM0"
Install the requisite packages.
sudo apt-get install gpsd gpsd-clients python-gps
Stop Daemons
sudo systemctl stop gpsd.socket
sudo systemctl disable gpsd.socket
Expose Service to public ports and localhost
vim /lib/systemd/system/gpsd.socket
Change 127.0.0.1 to 0.0.0.0
Stop GPSD services
sudo killall gpsd
Bind service to serial device
sudo gpsd /dev/ttyACM0 -F /var/run/gpsd.sock
Show GPS Data
gpsmon
This video shows step by step how to do what you are looking for.
How to install GPS on RaspberryPi
https://www.youtube.com/watch?v=A1zmhxcUOxw

How to sync time on host wake-up within VirtualBox?

I am running an Ubuntu 12.04-based box inside of Vagrant using VirtualBox. So far, everything is fine - except for one thing:
Let's assume that the VM is running. Then, the host goes to standby-mode. After waking it up again, the VM is still running, but its internal clock continues where it stopped when the host went down. So this basically means: Put the host to sleep for 15 minutes, wake it up again, then the VM's internal clock is 15 minutes late.
How can I fix this (setting the time manually is not an option for obvious reasons ;-))? Is there a way to run a script inside of a Vagrant VM whenever the host system changes its state?
I've read in the documentation that by default the VirtualBox Guest Additions sync the time with the host every 10 seconds. Apparently this is not happening, but I can not find any place where it is disabled. So any ideas?
PS: The Guest Additions are installed and match the version of VirtualBox being used.
The documentation lacks some details here.
What VirtualBox does every 10 seconds is just slight adjustement (something like 0.005 seconds). Only when the time difference reaches a threshold (20 minutes by default) a "real" resync is done.
You can reduce the thresold (i.e. to 10 seconds) with the following command:
VBoxManage guestproperty set <vm-name> "/VirtualBox/GuestAdd/VBoxService/--timesync-set-threshold" 10000
Summarizing answers of #zilupe and #Slobodan Kovacevic, solution is to add following to Vagrantfile:
config.vm.provider 'virtualbox' do |vb|
vb.customize [ "guestproperty", "set", :id, "/VirtualBox/GuestAdd/VBoxService/--timesync-set-threshold", 1000 ]
end
This will synchronize clocks each time when desync becomes > 1s (1000ms)
I give an other solution to sync time between guest & host without installing Virtualbox guest addition:
install ntp on your guest, and de-comment these lines in /etc/ntp.conf:
disable auth
broadcastclient
Then, restart ntp with service ntp restart
Active broadcast on your host:
For Linux users, edit your /etc/ntp.conf file and configure broadcast (you must adapt IP):
broadcast 192.168.123.255
For Windows users, activate the "Windows Time" service. You can then read this page to configure it to broadcast time
Then, restart time service on host.
For me to get timesync working I had to do this:
vboxmanage setextradata «machine-name» "VBoxInternal/Devices/VMMDev/0/Config/GetHostTimeDisabled" 0
It turns the timesync on. It was, for some reason, off.
I found a solution:
install ntpdate
add "s" permission for ntpdate, this allows non-root users to run ntpdate as root: sudo chmod u+s /usr/sbin/ntpdate
add one line in ~/.bashrc: ntpdate -u ntp.ubuntu.com
After that, each time you login to the linux system, the time will be sync once.
you can install the VirtualBox Guest Additions in the VM to sync the time automatically by VB.

Hook up Raspberry Pi via Ethernet to laptop without router? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 3 years ago.
Improve this question
I'm working on a balloon project with a Raspberry Pi. When we potentially recover the Raspberry Pi, it will most likely be in a rural location and I'd like to turn off the Pi at that point safely.
Without a router or network nearby, I was wondering if there is a way to hook up a Raspberry Pi with an Ethernet cable directly to a laptop?
It's a solution for Ubuntu (the idea also works for Windows or Mac) I just tried today and it works like a charm.
Material
a cross-over Ethernet cable (the name is fancy but it's just a normal Ethernet cable)
a laptop (ubuntu)
a Raspberry Pi (I have the Pi2)
Prerequisites on your ubuntu
Install network-manager
$sudo apt-get install network-manager
Install nmap
$sudo apt-get install nmap
Edit Wired connection on your laptop (Ubuntu)
Change IpV4 settings to "Share to other computers"
Save the setting
Reboot your laptop
Share WiFi connection of your laptop via Ethernet crossover cable
Hook up your RPi with your laptop using the Ethernet cable
Look up the broadcast address of the Ethernet connection (Laptop),
$/sbin/ifconfig eth1 | grep "Bcast" | awk -F: '{print $3}' | awk '{print $1}' 10.42.0.255
Use this address to find out the IP address of your RPi, it's 10.42.0.96 in my case because 10.42.0.1 is my laptop
$nmap -n -sP 10.42.0.255/24
Starting Nmap 6.40 ( http://nmap.org ) at 2016-02-20 23:07 CET
Nmap scan report for 10.42.0.1
Host is up (0.00031s latency).
Nmap scan report for 10.42.0.96
Host is up (0.0023s latency).
Nmap done: 256 IP addresses (2 hosts up) scanned in 2.71 seconds
Login to your RPi from your laptop (-Y with X-forwarding)
$ssh -Y pi#10.42.0.96
Lo and behold! Now your RPi is connected to your laptop and RPi can share the WiFi connection.
pi#raspberrypi ~ $
Share display & keyboard of your laptop with RPi
Install vncserver on Raspberry Pi
$ sudo apt-get update
$ sudo apt-get install tightvncserver
Install vncviewer on your laptop by downloading RealVNC (it supports multiple platforms)
http://www.realvnc.com/download/vnc/
To be able to copy & paste from VNC server <--> VNC viewer, you need to install autocutsel on your RPi.
$sudo apt-get install autocutsel
If this site doesn't work, try to download the .deb directly from a mirror site, e.g.
mirror.hmc.edu/debian/pool/main/a/autocutsel/autocutsel_0.10.0-1_armhf.deb
and install it
$sudo dpkg -i autocutsel_0.10.0-1_armhf.deb
Start vncserver on your RPi (You have to restart vncserver after installing autocutsel, you can issue $vncserver -kill :1)
$vncserver :1
Add autocutsel -fork to /home/pi/.vnc/xstartup
#!/bin/sh
xrdb $HOME/.Xresources xsetroot -solid grey
autocutsel -fork
#x-terminal-emulator -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
#x-window-manager &
# Fix to make GNOME work
export XKL_XMODMAP_DISABLE=1
/etc/X11/Xsession
Start vncviewer on your laptop
$vncviewer
A vncviewer window will pop up and type in the IP address of your RPi (given by your laptop) followed by port 1, which is your VNC server. for example: 10.42.0.96:1 in my case.
Connect it to the vncserver hosted on your RPi by typing in a password (set up a password yourself)
12.Now you can see the desktop of RPi on your laptop, and I opened my browser to show the shared WiFi connection is working as well.
See Raspberry Pi desktop on your ubuntu
No router + no screen + regular Ethernet cable + RPI 2 + Raspbian Lite 2018-11-13 + Ubuntu 18.10
First we must enable the SSH server on the Pi, which is disabled by default for security.
If you already have a shell on the Pi through a non-SSH method such as screen + keyboard or UART (see below), just run:
sudo systemctl enable ssh
sudo service sshd start
as explained at: https://raspberrypi.stackexchange.com/questions/58478/ssh-not-working-with-fresh-install This persists across boots.
Otherwise, insert he SD card on your host, and create a magic empty file named ssh file in the boot/ partition.
On Ubuntu hosts, it gets mounted automatically and you can do just:
sudo touch /media/$USER/boot/ssh
which you can confirm with:
lsblk
which contains:
mmcblk0 179:0 0 14.4G 0 disk
├─mmcblk0p1 179:1 0 43.9M 0 part /media/ciro/boot
└─mmcblk0p2 179:2 0 14.4G 0 part /media/ciro/rootfs
If you don't enable the SSHD daemon on the Pi then SSH connection will fail with:
ssh: connect to host 10.42.0.160 port 22: Connection refused
when we try it later on.
After enabling the SSH server
Next, boot the Pi, and link an Ethernet cable from your laptop directly to the Pi:
On Ubuntu 17.04 to work around this bug as mentioned on this answer you first need:
sudo apt-get install dnsmasq-base
On the host, open the network manager:
nm-connection-editor
And go:
+ sign (Add a new connection)
Ethernet
Create
IPv4 Settings
Method: Shared to other computers
Set a good name for it
Save
Find the IP of the Pi on host:
cat /var/lib/misc/dnsmasq.leases
outputs something like:
1532204957 b8:27:eb:0c:1f:69 10.42.0.160 raspberrypi 01:b8:27:eb:0c:1f:69
10.42.0.160 is the IP, then as usual:
ssh pi#10.42.0.160
I also have the following in my .bashrc:
piip() ( cat /var/lib/misc/dnsmasq.leases | cut -d ' ' -f 3; )
pissh() ( sshpass -p raspberry ssh "pi#$(piip)"; )
From inside the Pi, notice that it can access the internet normally through your host's other interfaces:
ping google.com
For example on my laptop, the Pi takes up the Ethernet, but the host is also connected to the internet through WiFi.
The crossover cable is not required if the host network card supports Auto MDI-X. This is the case for most recent hardware, including for example the 2012 Lenovo T430 I tested with, which has an "Intel® 82579LM Gigabit Network Connection" which documents support for Auto MDI-X.
Now you can also:
access the Internet from the PI through your Ubuntu's Wifi connection
open a VNC to get rid of the display as well: https://raspberrypi.stackexchange.com/questions/14611/how-to-set-up-raspberry-pi-without-a-monitor/54393#54393
UART serial USB converter
This is an alternative to SSH if you just want to get a shell on the Pi: https://en.wikipedia.org/wiki/Serial_port
This does not use SSH or networking itself, but rather the older, simpler, more direct, more reliable, lower bandwidth, lower distance serial interface. The Pi won't have access to the Internet with this method.
Desktop computers still have a serial port which you can connect directly wire to wire with the Pi, but these are hidden in most laptops, and so we need to buy a cheap USB adapter. Here I've used a "DSD TECH USB to TTL Serial Converter" https://www.amazon.co.uk/gp/product/B072K3Z3TL See also: https://unix.stackexchange.com/questions/307390/what-is-the-difference-between-ttys0-ttyusb0-and-ttyama0-in-linux/367882#367882
First plug the SD card on the host, and edit the config.txt file present in the first partition to add:
enable_uart=1
as explained at: https://www.raspberrypi.org/forums/viewtopic.php?f=28&t=141195
This first partition contains the bootloader, its configuration files and the (Linux / your) kernel, config.txt being one of them. The second partition contains the actual Linux root filesystem.
Now connect your computer to the Pi as:
You only need to attach 3 cables:
Ground to Ground
Tx on Pi to Rx on the USB to serial port
Rx on Pi to Tx on tye USB to serial port
This is also documented at: https://www.raspberrypi.org/documentation/usage/gpio/README.md
Be careful not to link the Ground to the 5V, I've already burned 2 UART to USB chips and a RPI UART by doing that!
You don't need to connect the 5V to the 5V at all. I think you can power your Pi like that, but I've read that this is a bad idea, just use the usual USB power source.
Finally, plug the USB side of the connector to your host computer, and get a shell with:
sudo apt install screen
sudo usermod -a -G dialout $USER
screen /dev/ttyUSB0 115200
Exit with Ctrl-A \.
Here is a video by Adafruit showing it: https://www.youtube.com/watch?v=zUBPeoLW16Q
See also
Similar question on RPI SE: https://raspberrypi.stackexchange.com/questions/3867/ssh-to-rpi-without-a-network-connection
You don't need a cross-over cable. You can use a normal network cable since the Raspberry Pi LAN chip is smart enough to reconfigure itself for direct network connections.
Cheers
I've just implemented and test this successfully. Same situation with my project, want to connect to a Raspberry Pi with no router or wifi. Just a simple ethernet cable.
Using ssh putty program put the address as
raspberrypi.local
Log and in and you can access the terminal.
Alternatively if VNC server is setup, use VNC server and put
raspberrypi.local:1
In the server address. input your VNC server password and you've now got GUI access to do what you want.
In may case it was run scripts in a remote location. In the posters situation, safely shutdown the Pi. Simples Pimples.
Configure static ip for your laptop and raspberry pi.
On the rapberryPI configure it as following.
pi#rpi>sudo nano /etc/network/interfaces
Then configure following as required to connect to your laptop.
iface eth0 inet static
address 192.168.1.81
netmask 255.255.255.0
broadcast 192.168.1.255
configure static ip on the raspberry pi:
sudo nano /etc/network/interfaces
and then add:
iface eth0 inet static
address 169.254.0.2
netmask 255.255.255.0
broadcast 169.254.0.255
then you can acces your raspberry via ssh
ssh pi#169.254.0.2
Here are the instructions for Windows users on connecting to a RPi by using just an Ethernet cable and a DHCP server. There is no need for a cross over cable, as the RPi can handle it. I have a blog post that documents this with pictures here which may be easier to follow.
Downloads
Download the DHCP Server for Windows (download link is here). Unzip the zip file and open the dhcpwiz application, which will configure the DHCP server.
DHCP Server Configuration
Hit next on the first screen.
On the second screen, look for a "Local Area Connection" row and verify its IP address is 0.0.0.0 and its status is enabled. Connect the Ethernet cable from the RPi to your laptop, and turn on the Pi. Hit refresh on this screen until the IP address changes to 169.254.*.*. If it is anything else then you should alter your network settings for the Local Area Connection (make sure it is not a static IP/DNS). Click on this Local Area Connection row and hit next.
Check HTTP (Web Server). This makes it much more easy to locate the RPi's IP address. Hit Next.
Take the defaults and hit Next until you get to the Writing the INI file screen. Check Overwrite existing file and hit the Write INI file button. Then hit Next.
On the final screen, check Run DHCP server immediately and hit `Finish.
DHCP Server and Obtaining the IP Address of your Raspberry PI
This launches the actual DHCP server, using the configuration you just created in the previous wizard. Click the Continue as tray app button, and the DHCP server will be minimized to your system tray.
Anywhere from 1 second to 5 minutes from now you will see an alert on the system tray with your laptop and your RPi's new IP address. This alert is really quick and you will probably miss it. Normally your RPi's IP is 169.254.0.2, but it could be *.01 or even something else. It is easier to access the DHCP server's web UI at http://localhost/dhcpstatus.xml. This will list the hostname as "raspberrypi" with its IP address.
Now you can putty or remote desktop into your RPi, and configure its wireless settings or whatever you want to do.
Trouble shooting
This can be somewhat finicky. I've had my connection appear to drop and have been unable to SSH back in using the IP address. Normally, I can restart the Pi and get the IP address again. Sometimes I have to restart both the RPi and the DHCP server. Sometimes I have to do this multiple times. At one point when I wasn't getting a connection for 15 minutes, I copied all of the files in the dhcpsrv2.5.1 folder to a new folder and tried again; it immediately worked.
You could use a cross-over ethernet cable - http://en.wikipedia.org/wiki/Ethernet_crossover_cable
Assuming your RPi is a DCHP Client, then best to run a simple DHCP server on your notebook to assign the RPi an IP address.
Yes, you can connect the raspberry direct to your PC without router.
For this is necessary that the raspberry and your computer are on the same subnet, and they both have a static ip configured (And an Ethernet cable connected between the two devices).
An ideal configuration would be the following:
Raspberry on eth0: IP: 192.168.1.10 SubNet: 255.255.255.0
Your PC: IP: 192.168.1.11 SubNet 255.255.255.0
To set a manual IP on raspberry you can follow this guide
In your PC you can set a manual IP in the network adapter settings,and the procedure depends on your operating system.
When you have configured the two static IP, you can connect to the raspberry via SSH using the IP set (192.168.1.10).
Another simpler method is to attach on GPIO a button to turn off the raspberry! Take a look here!
What worked for me was a combination of the answers from Nicole Finnie and Ciro Santilli along with some answers from elsewhere.
Setting up the pi
We will need to do two things: activate ssh on the pi, and configure the pi to use a static ip.
Activating ssh
Add a file called ssh in the boot partition of the sd card (not the /boot folder in the root partition). This is well documented other places.
Static ip
Open /etc/dhcpcd.conf on the pi's SD-card, and uncomment the example for a static ip (starts around line 40). Set the addresses to
# Example static IP configuration:
interface eth0
static ip_address=10.42.0.182/24
static routers=10.42.0.1
static domain_name_servers=10.42.0.1 8.8.8.8 fd51:42f8:caae:d92e::1
Setting up your laptop
First, make sure you have networkmanager (with GUI) installed on your laptop. Then, make sure dnsmasq is not running as a service:
systemctl status dnsmasq
If this command prints that the service is stopped, then you're good.
Next we have to config networkmanager. Open /etc/NetworkManager/NetworkManager.conf and add the following two lines at the top:
[main]
DNS=dnsmasq
Then reboot. This step might not be necessary. It might be sufficient to restart the NetworkManager service. Now go to the NetworkManager GUI (usually accessed by an icon in the corner of the screen) and choose Edit Connections... In the window that pops up, click the + icon to create a new connection. Choose Ethernet as the type and press Create.... Go to the IPv4 Settings tab and select the method Shared to other computers. Give the connection a good name and save.
Connect the Raspberry Pi and make sure your laptop is using your new connection as its ethernet connection. If it is, your pi should now have an ip given to it by your pc. You can find this by first running ifconfig. This should give you several blocks of text, one for each network interface. You're interested in the one that is something like enp0s25 or eth0. It should have a line that reads something similar to
inet 10.42.0.1 netmask 255.255.255.0 broadcast 10.42.0.255
look at the broadcast address (in this case 10.42.0.255). If it is different than mine, power off the pi and put the SD card back in your laptop to change the static ip_address to something where the first three numbers are the same as in your broadcast address. Also change the static routers and the first of the domain_name_servers to your laptop's inet address. Power the pi back on and connect it. Run ifconfig again to see that the addresses have not changed.
ssh into the pi
ssh pi#10.42.0.182
If you get connection refused, the pi isn't running an ssh server. If you get host unreachable, I'm sorry.
Hope this helps someone!