User avatar
piborg
Posts: 11
Joined: Thu May 03, 2012 8:47 am
Contact: Website

Re: Some starting pointers for talking between Windows and Raspberry Pi

Sun May 06, 2012 7:19 pm

Just some pointers for those of you struggling to work between a Windows machine and the Raspberry Pi.
Not all of these are needed, they are just things I like to have to make copying files and the like easier.
This has all been done with the Debian "squeeze" distribution, but may work with other linux distributions.

Setting up ethernet settings
Examples use:




Raspberry Pi IP address
192.168.0.199


Raspberry Pi netmask
255.255.255.0


Gateway / router IP address
192.168.0.1




Temporary change (will revert to normal at restart)


sudo ifconfig eth0 down
sudo ifconfig eth0 192.168.0.199

Permanent change


sudo nano /etc/network/interfaces
change iface eth0 line to replace dhcp with static
add the following lines after the edited line:

address 192.168.0.199
netmask 255.255.255.0
gateway 192.168.0.1



Starting the graphical environment (X11)
One time (will need to be done after each restart)


startx &

At startup (will be presented with a graphical login screen from now on)


sudo nano /etc/inittab
Look for the line starting with "id:" (also has "initdefault"), change the number between the first two colons to a "5"

Useful note
The default screen saver will use more CPU power then is really needed, I recommend replacing it with a blank screen by doing the following:


Click on the button in the bottom left of the screen
Select "Other"
Select "ScreenSaver Preferences"
Select the "Display Modes" tab
From the "Mode" list select "Blank Screen Only"
Close the window

Setup SSH (provides a linux terminal from another machine)
One time (will need to be done after each restart)


sudo /etc/init.d/ssh start

At startup (will be available as soon as the login prompt appears)


sudo update-rc.d ssh start 20 2 3 4 5

Accessing from Windows


Download PuTTY from http://www.chiark.greenend.org.....nload.html(putty.exe)
Enter the Raspberry Pi IP address into the hostname field, leave the other settings default and click open
Finally enter the user credentials as you would do on the Raspberry Pi itself, you should now have a linux prompt

Setup VNC (for other machines to access the Raspberry Pi graphical interface)
Install server program


sudo apt-get install tightvncserver

One time (will need to be done after each restart)


tightvncserver

Supply a password when prompted the first time, this will be needed on the connecting computer



At startup (will be available as soon as the login prompt appears)


Make sure you have followed the 'one time' instructions at least once to set the password
copy the supplied vncserver file into the /etc/init.d folder
sudo chmod +x /etc/init.d/vncserver
sudo update-rc.d vncserver defaults

Accessing from windows


Download the correct copy of TightVNC for your machine (32 or 64 bit) http://tightvnc.com/download.php
During the install make sure you install the viewer, the server is not required for this purpose
Run the TightVNC viewer, in the host field enter "IP address:1", e.g. 192.168.0.199:1
Click connect
Fill in the password you set earlier, you should be presented with a graphical environment

Accessing windows shares from the Raspberry Pi
In the following steps replace




'machine'
Windows machine


'share'
Windows share name


'user'
Windows user name


'pass'
Windows password


'mount'
Directory path on the Raspberry Pi to mount to, e.g. /mnt/win



without the single quotes

Make a directory to mount to (only need to do this once)


sudo mkdir 'mount'
sudo chown pi 'mount'

One time (will need to be done after each restart)


sudo mount.cifs //'machine'/'share' 'mount' -o rw,username='user',password='pass'

At startup (will be available as soon as the login prompt appears)


sudo nano /etc/fstab

Add the following line to the bottom of the file
//'machine'/'share' 'mount' cifs rw,credentials=/root/pw.txt 0 0


sudo nano /root/pw.txt

Add the next two lines to the file
username='user'
password='pass'



Note


When setup in this fashion permissions will depend on the windows settings for the user credentials provided
Anyone who can view the credentials file can read the password used!
PiBorg - Control robots from your Raspberry Pi at piborg.org

User avatar
piborg
Posts: 11
Joined: Thu May 03, 2012 8:47 am
Contact: Website

Re: Some starting pointers for talking between Windows and Raspberry Pi

Sun May 06, 2012 7:32 pm

Code for vncserver

#! /bin/sh

### BEGIN INIT INFO

# Provides: vncserver

# Required-Start: networking

# Required-Stop: networking

# Default-Start: 3 4 5

# Default-Stop: 0 6

### END INIT INFO

set -e

PATH="$PATH:/usr/X11R6/bin/"

# The Username:Group that will run VNC

export USER="pi"

#${RUNAS}

# The display that VNC will use

DISPLAY="1"

# Color depth (between 8 and 32)

DEPTH="16"

# The Desktop geometry to use.

#GEOMETRY="x"

#GEOMETRY="800x600"

#GEOMETRY="1024x768"

GEOMETRY="1280x1024"

# The name that the VNC Desktop will have.

NAME="my-vnc-server"

OPTIONS="-name ${NAME} -depth ${DEPTH} -geometry ${GEOMETRY} :${DISPLAY}"

. /lib/lsb/init-functions

case "$1" in

start)

log_action_begin_msg "Starting vncserver for user '${USER}' on localhost:${DISPLAY}"

su ${USER} -c "/usr/bin/vncserver ${OPTIONS}"

;;

stop)

log_action_begin_msg "Stoping vncserver for user '${USER}' on localhost:${DISPLAY}"

su ${USER} -c "/usr/bin/vncserver -kill :${DISPLAY}"

;;

restart)

$0 stop

$0 start

;;

esac

exit 0
PiBorg - Control robots from your Raspberry Pi at piborg.org

NickMon68
Posts: 28
Joined: Fri Nov 18, 2011 9:18 pm

Re: Some starting pointers for talking between Windows and Raspberry Pi

Sun May 06, 2012 7:34 pm

Excellent guide -  this is pretty much what I did on my first day with a Pi and its all very useful.

I would suggest changing this :

sudo mkdir 'mount'

to

sudo mkdir '\mount'

Just in case any one is in the wrong location...

bredman
Posts: 1415
Joined: Tue Jan 17, 2012 2:38 pm

Re: Some starting pointers for talking between Windows and Raspberry Pi

Sun May 06, 2012 7:35 pm

Thanks for putting in all of this effort. However, I''m not sure if this belongs in the "Absolute Beginners" area. You are dealing with concepts which are far beyond the average beginner.

For example, your instructions on setting the IP address make no reference of how to find the valid IP range, the valid gateway address, or the static address range. Very few beginners will have any chance of using these instructions.

It's also not clear why these instructions relate to working with Windows. There is no need to turn off DHCP to talk to a Windows PC.

I suggest that you could add these to the guides in the RPi wiki http://elinux.org/RPi_Guides Lots of people could expand and test once you lay the groundwork.

JerryRice
Posts: 24
Joined: Tue Jun 19, 2012 3:39 pm

Re: Some starting pointers for talking between Windows and R

Sun Jul 08, 2012 3:19 am

This was a great help. Thanks for taking the time to help people out!
Jerry Rice - alias

Eben has BALLS-OF-STEEL!

geezbeez
Posts: 28
Joined: Mon Jul 02, 2012 9:19 pm

Re: Some starting pointers for talking between Windows and R

Sun Jul 08, 2012 4:03 pm

I see what your getting at here and I'm sure a lot of intermediate and advanced level linux users would do some of this or the same but I don't think beginners should necessarily do these things, as they are not strictly necessary and theres no explanation as to why they should choose to do these things.
As they say there are a lot of ways to skin a cat and this is just one way.
Personally although I would install vncserver I would not just start it on every boot, Id explain how to start it and how to stop it and what it does, new users may like the familiar style to the interface, however I would encourage new users to use command line on the PI more than I would encourage them to use a graphical interface like vncserver, yes its there for them if they want it but as they learn new things they should learn to save the commands in shell scripts for reuse and not try to memorize menus and options (well that's my opinion).
I use mobaxterm as a windows client,which allows me to start graphical apps from the command line and drag and drop files between windows and a linux machine without mount points and without setting up any software on the PI.
I'm not saying this is better just different, if you only used vncserver in the past try mobaxterm, or some other linux terminal software that allows running graphical apps from command line. (for advanced users startx wont work from mobaxterm without some tinkering due to the way startx runs but you should be able to fix that, not that its strictly necessary as you can start graphical apps from the command line, all xterm provides is the menu drop downs and a picture background of your choice) Even new users can dig about to find out exactly what commands they are running when they click menu options from xterm and they can learn from this.

Startic IP, Its generally better to use DHCP and allocate the IP from your router (which incidentally likely runs linux just like your PI) or linux DHCP server. If you are connecting your Rasp PI to a windows machine though its a lot harder to do this because as all us linux fans know windows can be a real stinker connecting to anything that's not Windows . So yes users may want a static IP but only because its really hard to tell your windows machine, when you connect to this machine please use this IP address. Alternatively you could set up your Raspberry PI to allocate IP addresses to your windows machines, So yes you want your PI to always have the same IP but you dont necessarily want to achieve this by setting the IP as static on the PI.

Return to “Beginners”