XMEN BLOGGER: 2017

Thursday, December 21, 2017

Raspberry Pi - Ubuntu Mate - create-wireless-access-point-hostapd


From:
https://seravo.fi/2014/create-wireless-access-point-hostapd
https://help.ubuntu.com/community/WifiDocs/WirelessAccessPoint
https://help.ubuntu.com/community/WifiDocs/WiFiHowTo
https://askubuntu.com/questions/180733/how-to-setup-an-access-point-mode-wi-fi-hotspot

dashohoxha/install_wifi_access_point.sh
https://gist.github.com/dashohoxha/5767262
http://dashohoxha.blogspot.com.es/2013/06/how-to-setup-wifi-access-point-on-ubuntu.html

dnsmasq bug
https://bugs.launchpad.net/ubuntu/+source/dnsmasq/+bug/1464990

[GUIDE] Making infrastructure wifi hotspot on ubuntu 12.04/12.10 by ogyct
https://forum.xda-developers.com/showthread.php?t=2009381

https://unix.stackexchange.com/questions/119209/hostapd-will-not-start-via-service-but-will-start-directly
https://unix.stackexchange.com/questions/350333/starting-hostapd-fails-acs-unable-to-collect-survey-data
Ubuntu Forums
https://ubuntuforums.org/showthread.php?t=1488953

https://mail.gnome.org/archives/networkmanager-list/2017-April/msg00003.html
https://askubuntu.com/questions/19320/how-to-enable-or-disable-services
https://dajul.com/2011/01/06/solucion-al-error-insserv-warning-script-x-missing-lsb-tags-and-overrides/
https://askubuntu.com/questions/218/command-to-list-services-that-start-on-startup

rsyslog
https://www.raspberrypi.org/forums/viewtopic.php?t=122601
https://github.com/rsyslog/rsyslog/issues/35

https://ubuntu-mate.community/t/something-is-renaming-my-eth0-and-wlan0-interfaces/2884/7
https://askubuntu.com/questions/775597/how-to-use-onboard-wifi-on-raspberry-pi-3-with-ubuntu-server-16-04
https://askubuntu.com/questions/766131/set-static-ip-ubuntu-16-04
https://ubuntuforums.org/archive/index.php/t-1970451.html

Turn your Raspberry Pi into a wireless access point with Hostapd

Linux hotspotDo you want to make a computer function as a WLAN base station, so that other computers can use as it as their wifi access point? This can easily be done using the open source software Hostapd and compatible wifi hardware.

This is a useful thing to do if computer acting as a firewall or as a server in the local network, and you want to avoid adding new appliances that all require their own space and cables in you already crowded server closet. Hostapd enables you to have full control of your WLAN access point and also enhances security. By using Hostapd the system will be completely in your control, every line of code can be audited and the source of all software can be verified and all software can be updated easily. It is quite common that active network devices like wifi access points are initially fairly secure small appliances with Linux inside, but over time their vendors don’t provide timely security updates and local administrators don’t care to install them via some clumsy firmware upgrade mechanism. With a proper Linux server admins can easily SSH into it and run upgrades using the familiar and trusted upgrade channels that Linux server distributions provide.

The first step in creating wireless base station with Hostapd is to make sure the WLAN hardware supports running in access point mode. Examples are listed in the hostapd documentation. A good place to shop for WLAN cards with excellent Linux drivers is thinkpenguin.com and in their product descriptions the WLAN card supported operation modes are nicely listed.

The next step is to install the software called Hostapd by Jouni Malinen and others. This is a very widely used software and it most likely is available in your Linux distribution by default. Many of the WLAN router appliances available actually are small Linux computers running hostapd inside, so by running hostapd on a proper Linux computer will give you at least all the features available in the WIFI routers, including advanced authentication and logging.

Our example commands are for Ubuntu 14.04. You need to have access to install hostapd and dnsmasq Dnsmasq is a small DNS/DHCP server which we’ll use in this setup. To start simply run:

sudo apt-get install hostapd dnsmasq

After that you need to create and edit the configuration file:

zcat /usr/share/doc/hostapd/examples/hostapd.conf.gz | sudo tee -a /etc/hostapd/hostapd.conf
The configuration file /etc/hostapd/hostapd.conf is filled with configuration examples and documentation in comments. The relevant parts for a simple WPA2 protected 802.11g network with the SSID ‘Example-WLAN‘ and password ‘PASS‘ are:

interface=wlan0
ssid=Example-WLAN
hw_mode=g
wpa=2
wpa_passphrase=PASS
wpa_key_mgmt=WPA-PSK WPA-EAP WPA-PSK-SHA256 WPA-EAP-SHA256

Next you need to edit the network interfaces configuration to force the WLAN card to only run in the access point mode. Assuming that the access point network will use the address space 192.168.8.* the file /etc/network/interfaces should look something like this:

# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback

auto wlan0
iface wlan0 inet static
hostapd /etc/hostapd/hostapd.conf
address 192.168.8.1
netmask 255.255.255.0
Then we need to have a DNS relay and DHCP server on our wlan0 interface so the clients actually get a working Internet connection, and this can be accomplished by configuring dnsmasq. Like hostapd it also has a very verbose configuration file /etc/dnsmasq.conf, but the relevant parts look like this:

interface=lo,wlan0
no-dhcp-interface=lo
dhcp-range=192.168.8.20,192.168.8.254,255.255.255.0,12h

Next we need to make sure that the Linux kernel forwards traffic from our wireless network onto other destination networks. For that you need to edit the file /etc/sysctl.conf and make sure it has lines like this:

net.ipv4.ip_forward=1

We need to activate NAT in the built-in firewall of Linux to make sure the traffic going out uses the external address as its source address and thus can be routed back. It can be done for example by appending the following line to the file /etc/rc.local:

iptables -t nat -A POSTROUTING -s 192.168.8.0/24 ! -d 192.168.8.0/24 -j MASQUERADE

Some WLAN card hardware might have a virtual on/off switch. If you have such hardware you might need to also run rfkill to enable the hardware using a command like rfkill unblock 0.

The same computer also runs Network Manager (as for example Ubuntu does by default) you need to edit it’s settings so that if won’t interfere with the new wifi access point. Make sure file /etc/NetworkManager/NetworkManager.conf looks like this:

[main]
plugins=ifupdown,keyfile,ofono
dns=dnsmasq

[ifupdown]
managed=false
Now all configuration should be done. To be sure all changes take effect, finish by rebooting the computer.

If everything is working, a new WLAN network should be detected by other devices.
On the WLAN-server you’ll see similar output from these commands:

$ iw wlan0 info
Interface wlan0
ifindex 3
type AP
wiphy 0

$ iwconfig
wlan0 IEEE 802.11bgn Mode:Master Tx-Power=20 dBm
Retry long limit:7 RTS thr:off Fragment thr:off
Power Management:off

$ ifconfig
wlan0 Link encap:Ethernet HWaddr f4:ec:38:de:c8:d2
inet addr:192.168.8.1 Bcast:192.168.8.255 Mask:255.255.255.0
inet6 addr: fe80::f6ec:38ff:fede:c8d2/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:5463040 errors:0 dropped:0 overruns:0 frame:0
TX packets:8166528 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:861148382 (861.1 MB) TX bytes:9489973056 (9.4 GB)

Monday, October 09, 2017

Raspberry Pi 1, 2 or 3 and Zero W - microSD Card Speed


From: Raspberrypi.org Forum
https://www.raspberrypi.org/forums/viewtopic.php?f=63&t=144493
https://www.raspberrypi.org/forums/viewtopic.php?f=29&t=188592


Recommended: Sandisk Ultra!!! 32Gb, 64Gb or 128Gb


-Test with a benchmark software (sdbench):

sudo nano sdbench.sh
sudo chmod +x sdbench.sh
sudo ./sdbench.sh


-To fully utilize the speeds for the card, you have to enable sd_overclock in /boot/config.txt:

dtparam=sd_overclock=100

NOTE: It has to be HC-1/UHS-1 or higher (like U1 or higher, or HC-I or higher).


-Run sdbench.sh:
32GB EVO+ Samsung UHS-1/HC-1 micro sdcard in a RPI3

pi@raspberrypi:~ $ sudo ./sdbench.sh

CONFIG:
CLOCK : 100.000 MHz
CORE : 500 MHz, turbo=1
DATA : 512 MB, /root/test.dat

HDPARM:
======
Timing O_DIRECT disk reads: 128 MB in 3.02 seconds = 42.41 MB/sec
Timing O_DIRECT disk reads: 128 MB in 3.05 seconds = 42.03 MB/sec
Timing O_DIRECT disk reads: 122 MB in 3.01 seconds = 40.50 MB/sec

WRITE:
=====
536870912 bytes (537 MB) copied, 27.4302 s, 19.6 MB/s
536870912 bytes (537 MB) copied, 27.386 s, 19.6 MB/s
536870912 bytes (537 MB) copied, 25.623 s, 21.0 MB/s

READ:
====
536870912 bytes (537 MB) copied, 12.312 s, 43.6 MB/s
536870912 bytes (537 MB) copied, 12.3474 s, 43.5 MB/s
536870912 bytes (537 MB) copied, 12.3233 s, 43.6 MB/s

RESULT (AVG):
============
Overlay config core_freq turbo overclock_50 WRITE READ HDPARM
500 1 100.000 MHz 19.12 MB/s 41.54 MB/s 41.63 MB/s


-Turbo mode:

sudo echo 10 > /sys/devices/system/cpu/cpufreq/ondemand/up_threshold
sudo echo 20 > /sys/devices/system/cpu/cpufreq/ondemand/sampling_down_factor

Thursday, April 13, 2017

Asteroid 2014 JO25 - 18th April 2017

More info at:
https://www.jpl.nasa.gov/news/news.php?feature=6807

And Espacio Profundo Forum:
http://www.espacioprofundo.com.ar/topic/27770-asteroide-2014-jo25/

And:
http://www.sociedadastronomia.com/Asteroide2014JO25.html

¿Cómo localizar el Asteroide 2014 JO25?

Mirando hacia el ESTE, entre las 9:00 p.m. y 10:00 p.m. del 19 de Abril, 2017.

Tuesday, April 04, 2017

Canciones para aprender ingles - links!!!


Letras en Ingles

10 canciones que te ayudaran a aprender ingles de forma efectiva y rapida

01 ‘Blank Space’ de Taylor Swift
02 ‘If I Were a Boy’ de Beyoncé
03 ‘ The Heart Wants What It Wants’ de Selena Gomez
04 ‘Thinking Out Loud’ de Ed Sheeran
05 ‘Torn’ de Natalie Imbruglia
06 ‘ Somebody That I Used to Know’ de Gotye
07 ‘Every Breath You Take’ de Police
08 ‘Someone Like You’ de Adele
09 ‘Friday I’m in Love’ de The Cure
10 ‘Time After Time’ de Cindy Lauper

Once upon a time, Freddie said: di-ro-reeeeeee-ro!!! ;-P


EEEEEEEROOOOO

EEEEEEEROOOOO

ERO

DIRORERE RERERE ERO

DIRORERE RERERE ERO

ERO

DIRORERE RERERERO

ERO

ERO

EEEEEEEEEEERO

DIROREREEEEERO

DIRORERERO DIROREROOO DIDOREREREREEEEEERO

DIROREEEEEERO DIROREEEEEEEEEEEERO DIROREEEEEEEEEEEEEERO

DIROREREEEEEERO ERO ERO ERO

DIROREEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEERO!!!!!!!!


And Live at Wembley 11.7.1986 - A Kind Of Magic

Thursday, March 23, 2017

18650 Batteries


From: Battery Types, http://www.best18650battery.com/



-For Li-ion batteries

18 - The first two digits "18" stand for the battery diameter in millimeters. In this case width of the battery is 18mm (millimeters).
65 - The third, and fourth digit stand for length in millimeters. That would be 65mm.
0 - For simplicity just forget about the last digit zero for now.

-So what is a 16340 battery ?

16mm - diameter
34mm – length

Besides size and capacity, you may notice the 3 letter codes on most Li batteries like ICR, IMR, INR, NCR, etc. printed on the battery like the Samsung ICR18650-26F, INR18650-30Q, Panasonic NCR18650B, etc. These are various types of Li-ion batteries . The 3 letter codes are manufacturer codes, and most but not all, use this as a standard way to refer to the different types of cells.

“I_R”

The first Letter "I" just means that the cell is a Li-ion rechargeable.
Second letter refers to the cathode material.
The last letter "R" just means the cell is round.

ICR = Li-ion Rechargeable, the "C" = Cobalt.
IMR = the "M" stands for Manganese, or "Mn".
INR = the “N” stands for Nickel.
IFR = the "F" stands for the element "Fe" which is Iron.

INR seems to have rather similar proterties to IMR i.e. low internal resistance and delivery high current without causing the battery from getting too hot. It is also classified as a safer chemistry so it's another ideal high drain battery.

-What about Panasonic NCR18650B ?

The name NCR18650B is just Panasonic’s part number and it’s also a Lithium Cobalt battery, like an ICR cell. Panasonic does put some additional safety features that make it safest of any ICR cell.

The NCR18650B is available with and without protection. Again for protected cell, it may be offered as a rewrapped under different brand or same brand but the dimension will be longer and wider, so it may not suit some devices.

Capacity or mAh (milliampere hour) Rating - an approximation for how long a battery charge should last on a full charge. This is the battery capacity and is used to describe a battery's "fuel tank", as in general a battery with higher mAh ratings will last longer assuming that it's subjected to same usage patterns.

To estimate how long a battery last, divide the capacity of battery by the current consumed by device. For example, the battery is 3400mAh and a cree torch consumed 2.4A (2400mA), it will last 1.42 hours approx. If you use a 2600mAh, it last you only 1.08 hours only.

The "best battery" is not always the one with the largest mAh rating. In most applications a higher current rating (C-rating) determines the better battery.

The C rating is the maximum safe continuous discharge rate of a battery. If you see 10C on your battery, it means it can be discharged at 10 times that cell’s capacity. Capacity refers to the milliamp-hour rating of the battery, which will be listed as a number followed by mAh (2000mAh, for example). Here's the easy way to find your battery's discharge rate; just multiply the number from the C rating by the cell's capacity. Keep in mind that 1000 milliamps equals one amp.
Here's an example, using an 3.7V 2000mAh 10C

3.7 volt 2000mAh -10C
2000 milliamps = 2 amps
2 Amps x 10 = 20 amps continuous discharge

This means that you can safely draw up to 20 amps continuously from that 3.7V 2000mAh 10C without doing damage to your battery.

-Example: Samsung ICR18650 26-F 2600mAh 2C

It means the max. continuous discharge current is 5.2A (2.6x2). Now you know why this battery price is so low, because of low C-ratings and also not really a high capacity (mAh) battery.

Tuesday, March 21, 2017

Nagios - Windows passive PING


-Configure nsclient (NSC.ini):

[modules]
;# NSCLIENT++ MODULES
;# A list with DLLs to load at startup.
; You will need to enable some of these for NSClient++ to work.
; ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! !
; * *
; * N O T I C E ! ! ! - Y O U H A V E T O E D I T T H I S *
; * *
; ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! !
NSClientListener.dll
NRPEListener.dll

[Settings]
allowed_hosts=10.68.55.160
use_file=1

[NRPE]
port=5666
command_timeout=90

[NRPE Handlers]
passive_ping=c:\nsclient\pping.bat

-Create batch file (pping.bat):

@echo off
ping –n 1 178.60.210.204 -w 20000 >NUL
IF ERRORLEVEL 1 GOTO err
IF ERRORLEVEL 0 GOTO ok
GOTO unknown

:err
echo CRITICAL: Ping check failed
exit /B 2

:unknown
echo UNKNOWN: Something went wrong
exit /B 3

:ok
echo OK: Ping succeded
exit /B 0

Sunday, March 12, 2017

GoPro - DIY HandHeld Gimbal

3-Axis gimbal w/ Strom32 controller - HAKRC Strom32 BGC board

OPTION 1: RENOWATIO R - Storm32 & YS3 3X XML T6 **** W/ Big flashlight
Storm32 Software
OPTION 2: Electro Stunts - Storm32 StedyCam & YS3 3X XML T6 ***** Great Solution!!!
Storm32 StedyCam Software
OPTION 3: PERLE TV - 3 Axis DIY Handheld Gimbal & YS3 3X XML T6 **** Part 1/3
▻He uses same Storm32 StedyCam Software as OPTION 1
OPTION 4: tnxmatze - DIY Handheld Gimbal **** Little XML T6
OPTION 5: DIY Handheld 3axis Gimbal Stabilizer (without instructions)
OPTION 6: Cheap handheld 3axis gimbal - Storm32 board (Cheap Option w/out light hand)
OPTION 7: IWasHere - HAKRC Storm32 3 Axis Brushless Gimbal - GearBest
Storm32 Config file

Parts:
-HAKRC Storm32 3 Axis Brushless Gimbal Gopro3 / Gopro4 FPV Accessory (Aliexpress - $55)
-LED Flashlight YS3 3 x XML T6 1800 5 Modes Water Resistant 18650 LED (Aliexpress - $25)
-Joystick Controller HHG-JS for 3 Axis Basecam 8 32 Bits (Aliexpress - $10)

-Flashlight
http://www.banggood.com/Wholesale-E3-XM-L-T6-5-Modes-1600LM-Zoomable-LED-Flashlight-Suit-Set-2-x-18650-p-40234.html?p=PW08201889709201507X



Best handle(DIY) parts:
https://www.youtube.com/watch?v=3X6FxkMcF-k

Parts:
-Tripod
-USB Battery
-Swivel Torch Mount
-Mini Pocket Tripod Mount Stand Screw

GoPro USB Battery Grip DIY
https://www.youtube.com/watch?v=mnea-4-U4xo

https://www.youtube.com/watch?v=i0oZLogw7jY
Parts list:
- GoPro tripod mount - Can be bought at most places that sell GoPro accessories. Best Buy usually carries them or knock-offs can be bought on ebay.
- 1/2" CPVC pipe cap - Can be found at most hardware stores. DON'T buy a PVC cap. You want CPVC. They are different sizes.
- A short 1/4"-20 screw - This goes through the CPVC cap and into the GoPro tripod mount.
- One lock-on bicycle grip - These come in pairs only. Make sure you buy grips that have the locking rings on both ends of the grips. Can be found on Amazon.com, bicycle gear web sites, or your local bike shop.
- An external backup battery with USB charging outlet. This must be in the shape of a cylinder and have a diameter of 7/8" or 22mm.



From:
https://www.rcgroups.com/forums/showthread.php?1832271-DIY-Brushless-Gimbal-For-GoPro-Nex5

Low cost ,simple DIY project idea for "GoPro Brushless Gimbal",
Need little mod for adapting brushless motors, not finished mine yet, but developable,
I hope you like..

Part List:
Alexmos Simple Brushless Gimbal Controller or Opensource German Version
2-Axis Aluminium Aerial Photography PTZ from GLB 10$
1x Motor Mount from GLB 5$
1x HK 450 Carbon tail boom from HK 2.85$
2x Brushless Motors from HK Ready to use Brushless Gimbal Motors

-BaseCam (AlexMos) SimpleBGC
https://www.basecamelectronics.com/simplebgc/

Or

-Opensource German Version
https://code.google.com/archive/p/brushless-gimbal/

-GOPRO FPV Stability PTZ 2-Axis Aluminium Aerial Photography PTZ for Quadcopter - $10.66 SKU 90738
http://www.goodluckbuy.com/gopro-fpv-stability-ptz-2-axis-aluminium-aerial-photography-ptz-for-quadcopter-.html
Description:
- Type: Univerdal Two-axle Aerial Pan & Tilt
- Material: Aluminium
- Weight:64g(excluding servos)
- Silicon anti vibration
- For Quadcopter multicopter FPV system
- This set doesn't include Servos

Aluminum Brushless Motor 2212 2822 Mount for 12mm Fiber Glass Tube $5.74 SKU 77777
http://www.goodluckbuy.com/aluminum-brushless-motor-2212-2822-mount-for-12mm-fiber-glass-tube.html
Description:
- CNC made
- 6061 Aluminum material
- Used for 2212 2822 series motor
- Suited for 12mm glass/carbon Fiber tube
- Color:Black
- Weight: 9 gram
- Right part to built Muiticopter

-HK450 carbon tail boom €2.69
https://hobbyking.com/en_us/hk450-carbon-tail-boom.html
Description:
- HK450 carbon tail boom
- Length: 347mm
- Outer diameter: 12.45mm
- Inner diameter: 10.8mm



-GOPRO FPV 2-Axis Aluminium Photography PTZ with Two Sevos for Quadcopter $21.31 SKU 90739
http://www.goodluckbuy.com/gopro-fpv-2-axis-aluminium-photography-ptz-with-two-sevos-for-quadcopter-.html
Description:
- Type: Universal Two-axle Aerial Pan & Tilt
- Material: Aluminium
- Weight:127g(including two servos)
- Silicon anti vibration
- For Quadcopter multicopter FPV system
Package include:
- 1 x PTZ
- 1 x SG90 servo
- 1 x Gotech D9257 servo

-TowerPro SG90 9G Mini Servo with Accessories $3.28 SKU 52967
http://www.goodluckbuy.com/towerpro-sg90-9g-mini-servo-with-accessories.html
Description:
- Dimension : 22mm x 12mm x 29mm
- Weight : 9g
- Operating Speed : 0.12sec / 60 degrees (4.8V no load)
- Stall Torque : 1.5kg/cm at 4.8V
- Temperature Range : -30 to +60 Degree C
- Dead Band Width : 2 usec
- Operation Voltage : 3.0 - 7.2Volts
- Motor Type : coreless motor
- Gear Type : All Nylon Gear
- Connector Wire Length : 150mm



DJI Phantom Brushless Gimbal Camera Mount with Motor / GLB 3.1 2-Axis Brushless Gimbal MOS Controller for Gopro Hero 3 $30.34
http://www.xt-xinte.com/F07960.html

Saturday, March 04, 2017

Planetarium

-Planetarium
http://vega00.com/2017/03/cielo-simple-vista-marzo-2017.html/
https://www.timeanddate.com/eclipse/in/spain/barcelona
https://theskylive.com/planetarium

-Lluvia de estrellas
http://www.meteosolana.net/lluvia-de-estrellas/

-Eclipse Solar Eclipse August 21,2017
http://www.celestron.com/2017-eclipse-watch#entered
https://www.saros.org/eclipse-solar-21-08-2017/



Desde Barcelona no será visible!!





-Próximos eclipses en Barcelona






-Shops!!

http://www.telescopiosbarcelona.es/omegon/575-filtro-lunar-polarizado-omegon.html
http://www.telescopiosbarcelona.es/16-filtros-#/fabricante-teleskop_service
http://www.astroshop.es/omegon-cronus-wa-6-mm-1-25-/p,32982

Telescope Express - Calculating Magnification & Eyepieces


Calculating magnifications:

M=fo/fe; M=f(objective)/f(eyepiece)
 fo - Focal length telescope
 fe - Eyepiece focal

-Maximum magnification:
Mmax = 2 * Φ

-Minimum magnification:
Mmin = 2 * Φ / 10

-Best result Eyepiece (best magnification):
Er = fo / Φ



In my case, a Celestron NexStar 127SLT:

fo = 1500mm
 Φ = 127mm (D, diameter)
f/12

 9mm Eyepiece -> M=166x
12mm Eyepiece -> M=125x
25mm Eyepiece -> M=60x

Mmax = 2 * Φ = 254, then 254x
Mmin = 2 * Φ / 10 = 25.4, then 25.4x
  Er = 1500mm / 127mm = 11.8mm, then f/12 (12mm eyepiece)



More information at:
http://espacio846.blogspot.com.es/2011/08/como-calcular-los-aumentos-de-mi.html
http://www.astropractica.org/tab/config.htm
http://astrum.astrosabadell-labs.org/astrum/astrumpr-279ene17/html5/index.html

Raspberry Pi - SkyPi


From: http://wiki.neuralbs.com/index.php/SkyPi
& https://stargazerslounge.com/topic/180030-skyfi-with-a-pi/



DHCP/DNS

Don't want to have to remember the IP of the SkyPi and networks stuff... We start by naming the RPI as SkyPi-EQ6 (just so we are consistent with the rest of this document), but only for the wlan0 interface (the RPI's "real" name will remain SkyPi when plugged via eth0)

vim /etc/hosts
127.0.1.1 SkyPi
192.168.168.1 SkyPi-eq6

Now let's install dnsmasq and perform a minimal configuration (find and uncomment/modify the lines described below)

apt-get install dnsmasq
vim /etc/dnsmasq.conf

By default, all lines are comments, so simply add/modify the following lines:

interface=wlan0
dhcp-range=192.168.168.50,192.168.168.100,12h
port=0 # we don't want/need DNS

Now restart the service:

root@SkyPi:~# /etc/init.d/dnsmasq restart
[ ok ] Restarting DNS forwarder and DHCP server: dnsmasq.


Wednesday, March 01, 2017

NAS DNS-320L w/ Alt-F - Check RAID status



[root@DNS-320L]# cat /proc/mdstat

[root@DNS-320L]# mdadm --detail /dev/md1

[root@DNS-320L]# mdadm --examine /dev/sda2

[root@DNS-320L]# mdadm --examine /dev/sdb2

[root@DNS-320L]# cat /etc/mdadm.conf



- Examples:

[root@DNS-320L]# cat /proc/mdstat
Personalities : [linear] [raid0] [raid1] [raid6] [raid5] [raid4]
md1 : active raid1 sda2[2] sdb2[0]
      2929550672 blocks super 1.0 [2/1] [U_]
      [>....................] recovery = 1.6% (49317824/2929550672) finish=349.9min speed=137164K/sec
      bitmap: 22/22 pages [88KB], 65536KB chunk

unused devices: <none>
[root@DNS-320L]#

[root@DNS-320L]# mdadm --detail /dev/md1
/dev/md1:
        Version : 1.0
  Creation Time : Wed Mar 1 04:25:39 2017
     Raid Level : raid1
     Array Size : 2929550672 (2793.84 GiB 2999.86 GB)
  Used Dev Size : 2929550672 (2793.84 GiB 2999.86 GB)
   Raid Devices : 2
  Total Devices : 2
    Persistence : Superblock is persistent

  Intent Bitmap : Internal

    Update Time : Wed Mar 1 22:11:06 2017
          State : clean, degraded, recovering
 Active Devices : 1
Working Devices : 2
 Failed Devices : 0
  Spare Devices : 1

 Rebuild Status : 6% complete

           Name : DNS-320L:1 (local to host DNS-320L)
           UUID : 564d0424:9767531a:a3506da0:25799038
         Events : 49999

  Number Major Minor RaidDevice State
     0     8     18      0      active sync   /dev/sdb2
     2     8      2      1      spare rebuilding   /dev/sda2
[root@DNS-320L]#

Monday, February 27, 2017

Alt-F - How to convert a "standard" filesystem to RAID1 keeping all your data


From: Alt-F Wiki

Apply to DLink DNS-320/320L/321/323/325/327L with Alt-F firmware (free alternative firmware)



If you have a one disk "standard" filesystem and you which to convert it to RAID1, you can use one of the following procedures:

A - safest, no risk of data loss:
-Create a new degraded RAID1 with your new disk using Disk->Wizard (1)
-Copy all data from the old "standard" partition to the new RAID1 using Setup->Folders
-Verify that the data in the RAID1 is fine
-Change the old disk "standard" partition type to RAID using Disk->Partitioner (2)
-Add the old disk RAID partition to the new RAID as a new component using Disk->RAID

B - only works on disks smaller than 2TB, there is a data loss risk (3)
-Shrink your current "standard" filesystem using Disk->Filesystem
-Change the "standard" partition type to RAID using Disk->Partitioner (2)
-Unmount the filesystem using Disk->Filesystem
-Create a degraded RAID1 using the now RAID partition using Disk->RAID
-Enlarge the filesystem contained in the RAID using Disk->Filesystem
-Add a new disk and follow the How to fix a degraded RAID1 wiki

NOTES:
(1)-Make sure that the new disk in the only disk checked in the Disk Wizard upper section!
(2)-Make sure to only uncheck the "Keep" check-box for the "standard" partition, and then only change its type from "linux" to "RAID" -- don't change anything else!
(3) Bigger than 2.2TB disks requires a RAID metadata version 1.x. If using metadata version 1.1 or 1.2 your data will be lost. Metadata version 0.9 and 1.0 are safe.

Sunday, February 05, 2017

Celestron - Multi Finder Scope Mount


To mount something like this...


We need the following parts:

Multi-Slot Finder Scope Bracket $54.90
Smartphone Finder Scope $15.99
16x55mm Host/Housing/Case w Glass Lens $5.63
35mm Laser Pointer Bracket for Astronomical Telescope $19.99

Together $96.03 + shipping



-A Multiple Finder Scope mount:
Multi-Slot Finder Scope Bracket $54.90
or
Finder Scope mounting bracket $59.99


-A hold/housing for our laser module:
In my case, I have a 5.6mm TO-18 (Φ12mm) green laser (50mW) module, then I need something like this:
16x55mm Host/Housing/Case w Glass Lens $5.63

Another option is a laser holder pen for Φ12mm:
Adjustable Focusable Housing for Laser Pointer Torch $11.36
DIY Laser Pointer Pen Housing/Casing/Host for Φ12mm Laser Diode Module $5.80
Survival Laser C6 Host Assembly SL-SLC6LHA $19.99
More options:
Metal Housing/Case/Host 18x45mm $1.90
16x50mm Host/Housing/Shell with Lens $4.69
16x55mm Focusable Housing w/ Glass Lens $8.25
Accessories:
Unanodized Aluminum Heat Sink for Φ12mm Laser Diode Module $6.99

-A Finder Rings Adapter:
35mm Laser Pointer Bracket for Astronomical Telescope $19.99
Adjustable Pointer Finderscope Laser Bracket $27.71
Orion 52062 SkyLine Deluxe Laser Pointer-to-Telescope Bracket $36.83
NOTE: ORION 52062 can accommodate laser pointer devices with tubes ranging from 10.3mm (0.40") to 14.5mm (0.57") in diameter, and at least 8cm (3.1") long.

Other option:
Adjustable Mount for Φ12mm Laser Module £12.95
Two-axis Adjustable Laser Module $11.40

-Smartphone Finder Scope:
Smartphone Finder Scope $15.99


Thursday, February 02, 2017

Zener Diode as a Voltage regulator for GPS


- Zener:


- Regulador de voltaje:
You may try connect the 6V output to series with zener 5.6V and resistane (resistance power calculate) connect your output(between zener diode) to feedback of ADC Ref terminal. (ADC won't need exact 5V , you need some changes in programming) The resistor will dissipate excess voltage.

Connection diagram like this:

(6V positive) ---> resistance <---> zener5.6V ---> (6v negative) | | output + - Zener diode direction is most important.




How to Build a Voltage Regulator with a Zener diode
https://youtu.be/sHAa99W-08s
1KOhm (brown, black & red color) resistor and 1N4733 Zener

-Resistencias normalizadas (comerciales):




- Notas:
http://www.proyectoelectronico.com/fuentes-reguladores/reguladores-voltaje.html

- GPS:

GPS Module with Antenna

Uart TTL Output, Baud Rate 4800, 1HZ
1PPS Output: When GPS module get location, it will output 1PPS pulse every 1 second.

Note: This is GPS Module with Antenna, chip is Telit JF2 GPS, low power, SiRF IV.

Size: 28mm*28mm*8.5mm

About Pin:
1) VCC, 2.8V to 5.5V
2) GND
3) RX, no use
4) TX, Uart output, baud rate is 4800
5) 1PPS, when GPS module get location, it will output 1PPS signal every 1 second. The signal is active hign 100ms pulse




Sunday, January 29, 2017

Raspberry Pi - RetroPie configuration


-RetroPie SetUp
https://github.com/retropie/retropie-setup/wiki/manual-installation

-SSH configuration
https://github.com/retropie/retropie-setup/wiki/ssh

-Updating RetroPie
https://github.com/retropie/retropie-setup/wiki/updating-retropie

-Setting up PS3 controller
https://github.com/retropie/retropie-setup/wiki/Setting-up-a-PS3-controller

-Adding C64 emulator
https://www.youtube.com/watch?v=u2TwHKVYAZk

Green Laser Telescope for Astronomy


-Where to buy:

http://www.potentelaser.com/laser-verde-50mw-comprar.html

http://torlaser.com/es/2-greenpocket-puntero-laser-verde-50mw-de-torlaser.html



https://oxlasers.en.alibaba.com/product/916515069-218703343/OXLasers_OX_G306_1_100mW_burning_focusable_MINI_Green_Laser_Pointer_torch_light_matches_visible_green_beam.html

https://wholesaler.alibaba.com/product-detail/OXLasers-focusable-Green-Laser-Pointer-with_60406913165.html

http://www.telescopiomania.com/accesorios-para-telescopios-astronomicos/3173-laser-verde-lunatico-astronomia-con-soporte-para-telescopio.html?gclid=CMK8sK3Ro9ECFYwQ0wod3WEDOg

http://tienda.lunatico.es/



Cosmik - Soporte buscador laser universal
http://www.telescopiosbarcelona.es/55-laser-verde#/

Orion 52062 SkyLine Deluxe Laser Pointer-to-Telescope Bracket *******
http://www.ebay.com/itm/Orion-52062-SkyLine-Deluxe-Laser-Pointer-to-Telescope-Bracket-/122283404157?hash=item1c78a8ab7d:g:T-gAAOSwEzxYXtRE

Laser Pointer-to-Telescope Bracket
http://www.telescope.com/Accessories/Telescope-Finder-Scopes/Orion-SkyLine-Deluxe-Laser-Pointer-to-Telescope-Bracket/c/3/sc/49/p/52062.uts

Solomark Adjustable Laser Pointer Bracket
Laser Pointer Finderscope Bracket for Telescope - Astronomy
http://www.ebay.com/itm/Laser-Pointer-Finderscope-Bracket-for-Telescope-Astronomy-/201479155841?hash=item2ee917f081:g:-yUAAOSw6BtVUuI1



Orion Dual Finder Scope Mounting Bracket
http://www.telescope.com/Orion-Dual-Finder-Scope-Mounting-Bracket/p/102788.uts

Skywatcher Bracket Scope
http://www.ebay.com/itm/New-Standard-Deluxe-Multi-Slot-Finder-Scope-Bracket-for-Vixen-SkyWatcher-Finder-/361762099005?hash=item543ab38f3d:g:za0AAOSwzaJX7dgO

https://www.firstlightoptics.com/finders/flo-multi-finder-adapter-for-skywatcher.html



Telescope Smartphone Finder Scope Mirror Bracket for SKYATCHER ******
http://www.ebay.com/itm/Telescope-Smartphone-Finder-Scope-Mirror-Bracket-for-SKYATCHER-VIXEN-Standards-/172348431994?hash=item2820c45e7a:g:lJkAAOSwOyJX4Kp7

S8049 smartphone bracket
https://www.aliexpress.com/store/product/S8049-smartphone-bracket-Astronomical-telescope-phone-finder-scope-mirror-for-SKYATCHER-VIXEN-type/1371081_32350751366.html



Black Metal Small Dovetail Board Plate for Optical Telescope Finderscope



- DIY e.g. Red Laser Pointer

From:
http://laserpointerforums.com/f50/cheap-red-laser-300mw-build-pics-heavy-91508.html

Survival Laser DIY C6 Host Assembly 10.89$+1$(drilled driver pill)
Survival Laser Red Anodized Aluminum Heat Sink 7.99$
10pcs Aixiz Standard acrylic lens 12.00$/10=1.2$ each
Aixiz laser module 5.6mm 4.50$
2pcs Contact board (cheap led driver) 2.77$/2=1.385$ each
Aixiz adjustable current laser diode driver 80-500mA w/TTL 3.75$
10pcs Red Laser Diodes ML101U29-25 29.98$/10=2.998$ each

Together 33.72$+shipping






Raspberry Pi - Installing OS images on Mac


From:
https://www.raspberrypi.org/documentation/installation/installing-images/mac.md



-Open a terminal, then run:

diskutil list

Identify the disk (not partition) of your SD card e.g. disk4, not disk4s1.

-Unmount your SD card by using the disk identifier, to prepare for copying data to it:

diskutil unmountDisk /dev/disk

where disk is your BSD name e.g. diskutil unmountDisk /dev/disk4

-Copy the data to your SD card:

sudo dd bs=1m if=image.img of=/dev/rdisk

where disk is your BSD name e.g. sudo dd bs=1m if=2017-01-11-raspbian-jessie.img of=/dev/rdisk4

This may result in a dd: invalid number '1m' error if you have GNU coreutils installed. In that case, you need to use a block size of 1M in the bs= section, as follows:

sudo dd bs=1M if=image.img of=/dev/rdisk

This will take a few minutes, depending on the image file size. You can check the progress by sending a SIGINFO signal pressing Ctrl+T.

If this command still fails, try using disk instead of rdisk, for example:

sudo dd bs=1m if=2017-01-11-raspbian-jessie.img of=/dev/disk4

or

sudo dd bs=1M if=2017-01-11-raspbian-jessie.img of=/dev/disk4

-After the dd command finishes, eject the card:

sudo diskutil eject /dev/rdisk3



Or using ApplePi Baker for macOS!!!



Summary:

$ diskutil list
$ diskutil unmountDisk /dev/disk3
$ sudo dd bs=1m if=SDimage.img of=/dev/rdisk3
$ diskutil eject /dev/rdisk3



Format USB disk ( and ExFAT):

$ diskutil list
$ diskutil unmountDisk /dev/disk3
$ diskutil eraseDisk ExFAT Files /dev/disk3

or...

$ diskutil eraseDisk JHFS+ SDcard /dev/disk3

Where "Files" and "SDcard" is the lavel of the device.

Saturday, January 28, 2017

Raspberry Pi - Add Commodore 64 emulator to RetroPie


-VICE Emulator
https://github.com/retropie/retropie-setup/wiki/Commodore-64

-Install VICE on RetroPie (Video - Youtube)
https://www.youtube.com/watch?v=u2TwHKVYAZk

-Amiga emulator(UAE4ALL2) on Raspberry Pi
https://www.youtube.com/watch?v=1s1BJXzsoRM
https://www.raspberrypi.org/forums/viewtopic.php?f=78&t=102328

-ROMS
http://www.gametronik.com/site/emulation/commodore_c64/

-C64 Mod (RaspberryPi)
http://www.breadbox64.com/blog/c64-raspberrypi-mod/#comment-926
Note: Uses Neutrik connectors

-ROMS & Videos
https://c64endings.wordpress.com



ROMs compatibles *****
Tapes.c64.no

http://www.commodorezone.com/64tapef.htm

Monday, January 23, 2017

Cygwin - How to run a crontab


Install cron (Vixie's Cron) first!!! From Cygwin setup.exe!!!



From:
http://stackoverflow.com/questions/707184/how-do-you-run-a-crontab-in-cygwin-on-windows

You have two options:

1. Install cron as a windows service, using cygrunsrv:

cygrunsrv -I cron -p /usr/sbin/cron -a -D
net start cron

2. The 'non .exe' files are probably bash scripts, so you can run them via the windows scheduler by invoking bash to run the script, e.g.:

C:\cygwin\bin\bash.exe -l -c "./full-path/to/script.sh"



Hat tip http://linux.subogero.com/894/cron-on-cygwin/

Start the cygwin-setup and add the “cron” package from the “Admin” category.

We’ll run cron as a service by user SYSTEM. Poor SYSTEM therefore needs a home directory and a shell. The “/etc/passwd” file will define them.

$ mkdir /root
$ chown SYSTEM:root /root
$ mcedit /etc/passwd
SYSTEM:*:......:/root:/bin/bash

The start the service:

$ cron-config
Do you want to remove or reinstall it (yes/no) yes
Do you want to install the cron daemon as a service? (yes/no) yes
Enter the value of CYGWIN for the daemon: [ ] ntsec
Do you want the cron daemon to run as yourself? (yes/no) no
Do you want to start the cron daemon as a service now? (yes/no) yes

Local users can now define their scheduled tasks like this (crontab will start your favourite editor):

$ crontab -e # edit your user specific cron-table HOME=/home/foo
PATH=/usr/local/bin:/usr/bin:/bin:$PATH
# testing
* * * * * touch ~/cron @reboot ~/foo.sh 45 11 * * * ~/lunch_message_to_mates.sh

Domain users: it does not work. Poor cron is unable to run scheduled tasks on behalf of domain users on the machine. But there is another way: cron also runs stuff found in the system level cron table in “/etc/crontab”. So insert your suff there, so that SYSTEM does it on its own behalf:

$ touch /etc/crontab
$ chown SYSTEM /etc/crontab
$ mcedit /etc/crontab
HOME=/root
PATH=/usr/local/bin:/usr/bin:/bin:$PATH
* * * * * SYSTEM touch ~/cron
@reboot SYSTEM rm -f /tmp/.ssh*

Finally a few words about crontab entries. They are either environment settings or scheduled commands. As seen above, on Cygwin it’s best to create a usable PATH. Home dir and shell are normally taken from “/etc/passwd”.

As to the columns of scheduled commands see the manual page.

If certain crontab entries do not run, the best diagnostic tool is this:

$ cronevents



Applied the instructions from this answer and it worked Just to point out a more copy paste like answer (because cygwin installation procedure is kind of anti-copy-paste wise implemented).
Click WinLogo button , type cmd.exe , right click it , choose "Start As Administrator". In cmd prompt:

cd cygwin installer:
set package_name=cygrunsrv cron
setup-x86_64.exe -n -q -s http://cygwin.mirror.constant.com -P %package_name%

Ensure the installer does not throw any errors in the prompt ... If it has - you probably have some cygwin binaries running or you are not an Windows admin, or some freaky bug ...

Now in cmd promt:

C:\cygwin64\bin\cygrunsrv.exe -I cron -p /usr/sbin/cron -a -D
or whatever full file path you might have to the cygrunsrv.exe and start the cron as windows service in the cmd prompt

net start cron

Now in bash terminal run:

crontab -e

set up you cron entry an example bellow:

#sync my gdrive each 10th minute
*/10 * * * * /home/Yordan/sync_gdrive.sh

# * * * * * command to be executed
# - - - - -
# | | | | |
# | | | | +- - - - day of week (0 - 6) (Sunday=0)
# | | | +- - - - - month (1 - 12)
# | | +- - - - - - day of month (1 - 31)
# | +- - - - - - - hour (0 - 23)
# +--------------- minute

Saturday, January 21, 2017

DLink DNS-320L - Replacing fan


From: DLINK Forum
http://forums.dlink.com/index.php?topic=53051.30



I also decided to replace the noisy fan yesterday. This is what I did:

 1. Cut a hole on the top cover.
 2. Remove original fan.
 3. Attach new fan on the top...
    http://noctua.at/en/products/product-line-redux/nf-r8-redux-1200
 4. Switch polarity on the fan's connector.

The new fan has ultra low noise. Auto fan control works too. However, I set it to run "High" constantly. The new fan sucks air out of the chassis, so cold air flows in at the bottom/back (where the original fan was). When it is in idle, it is around 33/34 C degrees.



Gelid Silent 8 (fn-sx08-16)



If I put ramsinks:
http://forum.dsmg600.info/viewtopic.php?id=6574

--> The main board with ramsinks = no temp change!!

Wednesday, January 18, 2017

Relay Switches



Where to buy...

AC-220V-1-CH-Relay-Mini-Receiver-10A-Remote-Switch-Input-AC220V

Wireless-Remote-Control-Switch-AC-220V

IR Sensor Switch


Thursday, January 05, 2017

Nikon D7000 - Raspberry Pi as an Access Point to control your camera w/Raspbian


From:
http://dslrdashboard.info/
http://digicamcontrol.com/doc/



You need:

- Raspberry Pi 2B, because it has 4 USB port, and I need it to control my Nikon camera and my Celestron teelescope (if you need more info, check this) with Raspbian installed.
- USB Wifi dongle compatible.
- External battery (5V output) to do power to your Raspberry Pi.
- USB cable (USB to mini-USB), to connect raspberry pi to Nikon D7000 camera.

First step:

- Install Raspbian (if you have doubts, please check raspbian.org.

- Update your Raspberry Pi from repositories:

pi@raspsrv $ sudo apt-get update
pi@raspsrv $ sudo apt-get upgrade

- And install rpi-update:

pi@raspsrv $ sudo apt-get install rpi-update
pi@raspsrv $ sudo rpi-update

Please, reboot when finish!!

- Troubleshooting... (If needed)

pi@raspsrv $ sudo apt-get install ca-certificates

pi@raspsrv $ sudo apt-get install ntpdate
pi@raspsrv $ sudo ntpdate -u ntp.ubuntu.com

Second step:

Configure your Raspberry Pi as an Acces Point.

1. Install all that you need:

pi@raspsrv $ sudo apt-get install hostapd isc-dhcp-server

# Probably you don't need install this:
pi@raspsrv $ sudo apt-get install iptables-persistent

If you have a non-common WiFi adapter, you can update hostapd driver from adafruit...

pi@raspsrv $ wget http://adafruit-download.s3.amazonaws.com/adafruit_hostapd_14128.zip
pi@raspsrv $ unzip adafruit_hostapd_14128.zip

pi@raspsrv $ sudo mv /usr/sbin/hostapd /usr/sbin/hostapd.ORIG
pi@raspsrv $ sudo mv hostapd /usr/sbin
pi@raspsrv $ sudo chmod 755 /usr/sbin/hostapd

2. Edit your interfaces file to configure wlan0 adapter:

pi@raspsrv $ cat /etc/network/interfaces
auto lo

iface lo inet loopback
iface eth0 inet dhcp
#iface eth0 inet static
# address 192.168.0.190
# netmask 255.255.255.0
# gateway 192.168.0.1

allow-hotplug wlan0
#iface wlan0 inet manual
#wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
#iface default inet dhcp
iface wlan0 inet static
address 192.168.5.1
netmask 255.255.255.240
gateway 192.168.0.1

pre-up iptables-restore < /etc/iptables.ipv4.nat

3. Edit your DHCP daemon config file:

pi@raspsrv $ cat /etc/dhcp/dhcpd.conf
#
# Sample configuration file for ISC dhcpd for Debian
#
#

# The ddns-updates-style parameter controls whether or not the server will
# attempt to do a DNS update when a lease is confirmed. We default to the
# behavior of the version 2 packages ('none', since DHCP v2 didn't
# have support for DDNS.)
ddns-update-style none;

# option definitions common to all supported networks...
##option domain-name "example.org";
##option domain-name-servers ns1.example.org, ns2.example.org;

default-lease-time 600;
max-lease-time 7200;

# If this DHCP server is the official DHCP server for the local
# network, the authoritative directive should be uncommented.
#authoritative;
authoritative;

# Use this to send dhcp log messages to a different log file (you also
# have to hack syslog.conf to complete the redirection).
log-facility local7;

# No service will be given on this subnet, but declaring it helps the
# DHCP server to understand the network topology.

#subnet 10.152.187.0 netmask 255.255.255.0 {
#}

# This is a very basic subnet declaration.

#subnet 10.254.239.0 netmask 255.255.255.224 {
# range 10.254.239.10 10.254.239.20;
# option routers rtr-239-0-1.example.org, rtr-239-0-2.example.org;
#}

# This declaration allows BOOTP clients to get dynamic addresses,
# which we don't really recommend.

#subnet 10.254.239.32 netmask 255.255.255.224 {
# range dynamic-bootp 10.254.239.40 10.254.239.60;
# option broadcast-address 10.254.239.31;
# option routers rtr-239-32-1.example.org;
#}

# A slightly different configuration for an internal subnet.
#subnet 10.5.5.0 netmask 255.255.255.224 {
# range 10.5.5.26 10.5.5.30;
# option domain-name-servers ns1.internal.example.org;
# option domain-name "internal.example.org";
# option routers 10.5.5.1;
# option broadcast-address 10.5.5.31;
# default-lease-time 600;
# max-lease-time 7200;
#}

# Hosts which require special configuration options can be listed in
# host statements. If no address is specified, the address will be
# allocated dynamically (if possible), but the host-specific information
# will still come from the host declaration.

#host passacaglia {
# hardware ethernet 0:0:c0:5d:bd:95;
# filename "vmunix.passacaglia";
# server-name "toccata.fugue.com";
#}

# Fixed IP addresses can also be specified for hosts. These addresses
# should not also be listed as being available for dynamic assignment.
# Hosts for which fixed IP addresses have been specified can boot using
# BOOTP or DHCP. Hosts for which no fixed address is specified can only
# be booted with DHCP, unless there is an address range on the subnet
# to which a BOOTP client is connected which has the dynamic-bootp flag
# set.
#host fantasia {
# hardware ethernet 08:00:07:26:c0:a5;
# fixed-address fantasia.fugue.com;
#}

# You can declare a class of clients and then do address allocation
# based on that. The example below shows a case where all clients
# in a certain class get addresses on the 10.17.224/24 subnet, and all
# other clients get addresses on the 10.0.29/24 subnet.

#class "foo" {
# match if substring (option vendor-class-identifier, 0, 4) = "SUNW";
#}

#shared-network 224-29 {
# subnet 10.17.224.0 netmask 255.255.255.0 {
# option routers rtr-224.example.org;
# }
# subnet 10.0.29.0 netmask 255.255.255.0 {
# option routers rtr-29.example.org;
# }
# pool {
# allow members of "foo";
# range 10.17.224.10 10.17.224.250;
# }
# pool {
# deny members of "foo";
# range 10.0.29.10 10.0.29.230;
# }
#}

subnet 192.168.5.0 netmask 255.255.255.240 {
range 192.168.5.5 192.168.5.10;
option broadcast-address 192.168.5.15;
option routers 192.168.5.1;
default-lease-time 600;
max-lease-time 7200;
option domain-name "wifi.local";
option domain-name-servers 8.8.8.8, 8.8.4.4;
}

4. Edit your DHCP server config file:

pi@raspsrv / $ cat /etc/default/isc-dhcp-server
# Defaults for isc-dhcp-server initscript
# sourced by /etc/init.d/isc-dhcp-server
# installed at /etc/default/isc-dhcp-server by the maintainer scripts

#
# This is a POSIX shell fragment
#

# Path to dhcpd's config file (default: /etc/dhcp/dhcpd.conf).
#DHCPD_CONF=/etc/dhcp/dhcpd.conf

# Path to dhcpd's PID file (default: /var/run/dhcpd.pid).
#DHCPD_PID=/var/run/dhcpd.pid

# Additional options to start dhcpd with.
# Don't use options -cf or -pf here; use DHCPD_CONF/ DHCPD_PID instead
#OPTIONS=""

# On what interfaces should the DHCP server (dhcpd) serve DHCP requests?
# Separate multiple interfaces with spaces, e.g. "eth0 eth1".
##INTERFACES=""
INTERFACES="wlan0"

5. Edit your host APD config file:

pi@raspsrv / $ cat /etc/hostapd/hostapd.conf
interface=wlan0
driver=nl80211
#driver=rtl871xdrv
ssid=MyPi
hw_mode=g
channel=6
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_passphrase=Raspb3rry
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP

6. Edit your host APD daemon config file:

pi@raspsrv / $ cat /etc/default/hostapd
# Defaults for hostapd initscript
#
# See /usr/share/doc/hostapd/README.Debian for information about alternative
# methods of managing hostapd.
#
# Uncomment and set DAEMON_CONF to the absolute path of a hostapd configuration
# file and hostapd will be started during system boot. An example configuration
# file can be found at /usr/share/doc/hostapd/examples/hostapd.conf.gz
#
#DAEMON_CONF=""
DAEMON_CONF="/etc/hostapd/hostapd.conf"

# Additional daemon options to be appended to hostapd command:-
# -d show more debug messages (-dd for even more)
# -K include key data in debug messages
# -t include timestamps in some debug messages
#
# Note that -B (daemon mode) and -P (pidfile) options are automatically
# configured by the init.d script and must not be added to DAEMON_OPTS.
#
#DAEMON_OPTS=""

7. Edit your SYSCTL config file:

pi@raspsrv / $ cat /etc/sysctl.conf
#
# /etc/sysctl.conf - Configuration file for setting system variables
# See /etc/sysctl.d/ for additonal system variables
# See sysctl.conf (5) for information. #

#kernel.domainname = example.com

# Uncomment the following to stop low-level messages on console kernel.printk = 3 4 1 3

###############################################################
# Functions previously found in netbase
#

# Uncomment the next two lines to enable Spoof protection (reverse-path filter)
# Turn on Source Address Verification in all interfaces to
# prevent some spoofing attacks
#net.ipv4.conf.default.rp_filter=1
#net.ipv4.conf.all.rp_filter=1

# Uncomment the next line to enable TCP/IP SYN cookies
# See http://lwn.net/Articles/277146/
# Note: This may impact IPv6 TCP sessions too
#net.ipv4.tcp_syncookies=1

# Uncomment the next line to enable packet forwarding for IPv4
#net.ipv4.ip_forward=1
net.ipv4.ip_forward=1

# Uncomment the next line to enable packet forwarding for IPv6
# Enabling this option disables Stateless Address Autoconfiguration
# based on Router Advertisements for this host
#net.ipv6.conf.all.forwarding=1


###################################################################
# Additional settings - these settings can improve the network
# security of the host and prevent against some network attacks
# including spoofing attacks and man in the middle attacks through
# redirection. Some network environments, however, require that these
# settings are disabled so review and enable them as needed.
#
# Do not accept ICMP redirects (prevent MITM attacks)
#net.ipv4.conf.all.accept_redirects = 0
#net.ipv6.conf.all.accept_redirects = 0
# _or_
# Accept ICMP redirects only for gateways listed in our default
# gateway list (enabled by default)
# net.ipv4.conf.all.secure_redirects = 1
#
# Do not send ICMP redirects (we are not a router)
#net.ipv4.conf.all.send_redirects = 0
#
# Do not accept IP source route packets (we are not a router)
#net.ipv4.conf.all.accept_source_route = 0
#net.ipv6.conf.all.accept_source_route = 0
#
# Log Martian Packets
#net.ipv4.conf.all.log_martians = 1
#

# rpi tweaks
vm.swappiness=1
vm.min_free_kbytes = 8192

8. Add a iptables file:

pi@raspsrv / $ cat /etc/iptables.ipv4.nat
# Generated by iptables-save v1.4.14 on Thu Nov 26 08:15:51 2015
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m comment --comment "Accept all ingoing" -j ACCEPT
-A FORWARD -i eth0 -o wlan0 -m state --state RELATED,ESTABLISHED -j ACCEPT
-A FORWARD -i wlan0 -o eth0 -j ACCEPT
-A OUTPUT -m comment --comment "Accept all outgoing" -j ACCEPT
COMMIT
# Completed on Thu Nov 26 08:15:51 2015
# Generated by iptables-save v1.4.14 on Thu Nov 26 08:15:51 2015
*nat
:PREROUTING ACCEPT [0:0]
:INPUT ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
:POSTROUTING ACCEPT [0:0]
-A POSTROUTING -o eth0 -j MASQUERADE
-A POSTROUTING -o eth0 -j MASQUERADE
-A POSTROUTING -o wlan0 -j MASQUERADE
-A POSTROUTING -o eth0 -j MASQUERADE
COMMIT
# Completed on Thu Nov 26 08:15:51 2015

9. Add a iptables file:

pi@raspsrv / $ cat /etc/iptables.ipv4.nat
pi@raspsrv $ sudo service hostapd start
pi@raspsrv $ sudo service isc-dhcp-server start

pi@raspsrv $ sudo service hostapd status
pi@raspsrv $ sudo service isc-dhcp-server status

pi@raspsrv $ sudo update-rc.d hostapd enable
pi@raspsrv $ sudo update-rc.d isc-dhcp-server enable

Third step

- Download, Install and Confiure DSLR Dashboard server (ddserver)

1. Clone GitHub reposiroty and compile:
pi@raspsrv $ pwd
/home/pi
pi@raspsrv $ git clone git://github.com/hubaiz/DslrDashboardServer package/DslrDashboardServer
pi@raspsrv $ cd package/DslrDashboardServer
pi@raspsrv $ sudo make menuconfig

pi@raspsrv $ sudo apt-get install build-essential pkg-config libusb-1.0-0-dev
pi@raspsrv $ sudo g++ -Wall src/main.cpp src/communicator.cpp `pkg-config --libs --cflags libusb-1.0` -lpthread -lrt -lstdc++ -o ddserver

2. Move to /usr/local/bin:

pi@raspsrv $ cd /home/pi/package
pi@raspsrv $ sudo mv DslrDashboardServer /usr/local/bin/DslrDashboardServer

/usr/local/bin/DslrDashboardServer/ddserver

- Create and add ddserver script on startup

pi@raspsrv /etc/init.d $ cat ddserver.sh
#!/bin/sh

### BEGIN INIT INFO
# Provides: ddserver
# Required-Start: $all
# Required-Stop:
# Should-Start:
# Should-Stop:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: DslrDashboardServer daemon
# Description: Access and Control DSLR Cameras
### END INIT INFO

DIR=/usr/local/bin/DslrDashboardServer
DAEMON=$DIR/ddserver
DAEMON_NAME=ddserver
DAEMON_OPTS=""
DAEMON_USER=root

PIDFILE=/var/run/$DAEMON_NAME.pid

. /lib/lsb/init-functions

do_start () {
log_daemon_msg "Starting system $DAEMON_NAME daemon"
start-stop-daemon --start --background --pidfile $PIDFILE --make-pidfile --user $DAEMON_USER --chuid $DAEMON_USER --startas />$DAEMON -- $DAEMON_OPTS
log_end_msg $?
}
do_stop () {
log_daemon_msg "Stopping system $DAEMON_NAME daemon"
start-stop-daemon --stop --pidfile $PIDFILE --retry 10
log_end_msg $?
}

case "$1" in
start|stop)
do_${1}
;;
restart|reload|force-reload)
do_stop
do_start
;;
status)
status_of_proc "$DAEMON_NAME" "$DAEMON" && exit 0 || exit $?

;;
*)
echo "Usage: /etc/init.d/$DAEMON_NAME {start|stop|restart|status}"
exit 1
;;
esac
exit 0

pi@raspsrv $ cp -p ddserver.sh /etc/init.d
pi@raspsrv $ sudo chmod u+x /etc/init.d/ddserver.sh
pi@raspsrv $ sudo update-rc.d /etc/init.d/ddserver.sh defaults

pi@raspsrv $ cp your_script /etc/init.d/
pi@raspsrv $ sudo chmod u+x /etc/init.d/your_script
pi@raspsrv $ sudo update-rc.d /etc/init.d/your_script defaults

Nikon D7000 - DIY DSLR External Battery Pack



From:
http://itschriswinter.com/dslr-video/the-ultimate-dslr-external-battery/
https://fstoppers.com/video/diy-dslr-external-battery-pack-get-9-hours-shooting-9433



You need the following items that you can buy on Amazon or eBay or Aliexpress:

- (Anker) XTPower MP-10000 External Battery Pack 9v-12v
- Battery Dummie (DC Coupler for EP-5B, Nikon D7x00)
- Cheeseplate - SmallRig Camera Mounting Plate
- Hot Shoe Adapter
- Adhesive Velcro

Wednesday, January 04, 2017

Raspberry Pi - Pharos Microsoft GPS-360


FROM:
http://astrobeano.blogspot.com.es/2012/10/pharosmicrosoft-gps-360-on-raspberry-pi.html



I bought a Microsoft GSP-360 USB dongle on eBay as an impulse purchase, toying with the idea of running a Raspberry Pi in my car for live map display or at least route tracking for contributing road traces to the Open Street-Map project.
Just getting my location out of it proved harder than I'd expected.

The front of the dongle has a big Microsoft logo, while the sticker on the back (which has a bright blue LED when active) says:

  P/N: X11-49577
  360-1000-02
  S/N: ...
  GPS-360
  Tested to comply with FCC standards
  Rating: DC 3.5 - 5.5V 70mA
  Pharos USA
  SiRF Powered
  Made in China

For running this with a Raspberry Pi that current information could be useful, and the broad voltage tolerance is reassuring.
What do we learn at the command line? It appears as a Profilic USB/Serial adaptor at the USB level - here's what my Mac tells me:

$ system_profiler SPUSBDataType
...
  USB-Serial Controller:

   Product ID: 0xaaa0
   Vendor ID: 0x067b (Prolific Technology, Inc.)
   Version: 3.00
   Serial Number: 12345678
   Speed: Up to 12 Mb/sec
   Manufacturer: Prolific Technology Inc.
   Location ID: 0xfa130000 / 6
   Current Available (mA): 500
   Current Required (mA): 500

And in Linux, running on a Raspberry Pi (with no other devices attached):

$ lsusb
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 002: ID 0424:9512 Standard Microsystems Corp.
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp.
Bus 001 Device 004: ID 067b:aaa0 Prolific Technology, Inc. Prolific Pharos

USB/Serial Drivers

I should be able to talk to the USB-serial port, but to do on the Mac it seems I must first install a Prolific USB-serial driver. That's what this and this helpful blog told me.
Finding the Prolific USB/serial driver for Mac OS X took a while, it was hiding behind a "GUEST"/"GUEST" password protected page - but I eventually found md_PL2303_MacOSX10.6_dmg_v1.4.0.zip released 2011/05/13 which claims to support OS X 10.8 Mountain Lion.
There's also an open source driver, osx-pl2303 on SourceForge (SVN latest updated Jan 2008), forked as osx-pl2303 on Github (last updated Nov 2011), reported to have been tested under Mac OS X 10.7 Lion and 10.8 Mountain Lion. I punted on this.

As an aside, finding drivers for older versions of Windows was quite easy, but Profilic won't support their older PL-2303HXA and PL-2303X chips under Windows 8, using this as a stick to encourage people to buy their newer PL2303TA chip instead. Ouch.

For Linux there drivers should be already installed - so I went with that. Here's an excerpt from the Raspberry Pi boot log (with the GSP-360 dongle as the only external USB device plugged in):

$ dmseg
...
[ 38.098548] usb 1-1.3: new full-speed USB device number 4 using dwc_otg
[ 38.200535] usb 1-1.3: New USB device found, idVendor=067b, idProduct=aaa0
[ 38.200565] usb 1-1.3: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[ 38.200581] usb 1-1.3: Product: USB-Serial Controller
[ 38.200595] usb 1-1.3: Manufacturer: Prolific Technology Inc.
[ 38.200608] usb 1-1.3: SerialNumber: 12345678
[ 38.270238] usbcore: registered new interface driver usbserial
[ 38.272087] USB Serial support registered for generic
[ 38.273859] usbcore: registered new interface driver usbserial_generic
[ 38.273887] usbserial: USB Serial Driver core
[ 38.283343] USB Serial support registered for pl2303
[ 38.283511] pl2303 1-1.3:1.0: pl2303 converter detected
[ 38.290249] usb 1-1.3: pl2303 converter now attached to ttyUSB0
[ 38.291944] usbcore: registered new interface driver pl2303
[ 38.291972] pl2303: Prolific PL2303 USB to serial adaptor driver

As per that log, the new serial port is available as /dev/ttyUSB0

$ ls -l /dev/ttyUSB0
crw-rw---T 1 root dialout 188, 0 Oct 11 15:57 /dev/ttyUSB0

I'm using the default image here, username 'pi', and I am therefore a member of the dialout group so should be able to connect to this device:

$ groups
pi adm dialout cdrom sudo audio video plugdev games users input

Strangely I didn't (immediately) get anything from the device using a low level check:

$ cat /dev/ttyUSB0
(nothing)

GPSD

It seems the main low-level GPS software for Linux is gpsd, so I installed that and tried to run it.

$ sudo apt-get install gpsd gpsd-clients
...

Encouragingly the GPSD hardware page says support for the Microsoft GPS-360 is good, they test it before each release, and it should be plumbed into the Linux hotplug system to start gpsd automatically.

Rebooting with the GPS attached should create /dev/gps0 as an alias for /dev/ttyUSB0 and start the gpsd daemon automatically, check with:

$ ps -e | grep gpsd
307 ? 00:00:00 gpsd

In this case it is running (with process identifier 307). Similarly, if you boot up without the dongle and then plug it in, it should be recognised as gpsd started automatically. If it is running, this should kill it (advice from the GPSD Troubleshooting page):

$ sudo killall gpsd
$ sudo rm /var/run/gpsd.sock

You can (re)start it manually with:

$ gpsd /dev/ttyUSB0

I then tried a little test (with the daemon off):

$ gpsctl -f -n /dev/ttyUSB0 gpsctl:SHOUT: vendor/product match with 091e:0003 not found
gpsctl:ERROR: packet recognition timed out.

That isn't good... the -f meant without using the deamon mode of gpsd, the -n meant switch to NMEA mode. When it works I got this and could look at the raw NMEA output:

$ gpsctl -f -n /dev/ttyUSB0
gpsctl:SHOUT: vendor/product match with 091e:0003 not found
gpsctl:SHOUT: /dev/ttyUSB0 identified as a SiRF binary at 4800.
gpsctl:SHOUT: switching to mode NMEA.

$ cat /dev/ttyUSB0
$GPGGA, ...

Incidentally, until I read this blog post about why GPS support sucks, I'd been under the impression that NMEA 0183 was a good standard.

The GPSD Troubleshooting suggests starting with xgps or cgps. When cgps works:

$ cgps
┌───────────────────────────────────────────┐┌─────────────────────────────────┐
│ Time: 2012-10-11T17:06:42.920Z ││PRN: Elev: Azim: SNR: Used: │
│ Latitude: 56.XXXXXX N ││ 1 XX XXX XX Y │
│ Longitude: 3.XXXXXX W ││ 11 XX XXX XX Y │
│ Altitude: 58.9 m ││ 32 XX XXX XX Y │
│ Speed: 1.4 kph ││ 20 XX XXX XX Y │
│ Heading: 215.3 deg (true) ││ 14 XX XXX XX Y │
│ Climb: 12.8 m/min ││ 28 XX XXX XX Y │
│ Status: 3D FIX (3 secs) ││ 19 XX XXX XX Y │
│ Longitude Err: +/- 10 m ││ 17 XX XXX XX Y │
│ Latitude Err: +/- 11 m ││ 11 XX XXX XX Y │
│ Altitude Err: +/- 32 m ││ │
│ Course Err: n/a ││ │
│ Speed Err: +/- 84 kph ││ │
│ Time offset: 0.509 ││ │
│ Grid Square: IO86kk ││ │
└───────────────────────────────────────────┘└─────────────────────────────────┘
{"class":"DEVICES","devices":[{"class":"DEVICE","path":"/dev/ttyUSB0","activated":"2012-10-11T17:06:39.461Z","flags":1,"driver":"SiRF binary","subtype":...

I've masked out my exact location. Note CPU usage running gpsd and cgps with the default SiRF binary protocol was about 8%.

However, after rebooting and immediately running cgps it starts, waits for a bit with missing location information, then quits with a time out:

$ cgps
┌───────────────────────────────────────────┐┌─────────────────────────────────┐
│ Time: n/a ││PRN: Elev: Azim: SNR: Used: │
│ Latitude: n/a ││ │
│ Longitude: n/a ││ │
│ Altitude: n/a ││ │
│ Speed: n/a ││ │
│ Heading: n/a ││ │
│ Climb: n/a ││ │
│ Status: NO FIX (0 secs) ││ │
│ Longitude Err: n/a ││ │
│ Latitude Err: n/a ││ │
│ Altitude Err: n/a ││ │
│ Course Err: n/a ││ │
│ Speed Err: n/a ││ │
│ Time offset: n/a ││ │
│ Grid Square: n/a ││ │
└───────────────────────────────────────────┘└─────────────────────────────────┘
{"class":"WATCH","enable":true,"json":true,"nmea":false,"raw":0,"scaled":false,"timing":false} cgps: GPS timeout

I also ran into this:

$ gpsctl -n /dev/ttyUSB0
gpsctl:ERROR: error 'Multiple subscribers, cannot change control bits on /dev/ttyUSB0.'
gpsctl:ERROR: /dev/ttyUSB0 mode change to NMEA failed

And:

$ cat /dev/ttyUSB0
cat: /dev/ttyUSB0: Device or resource busy

I'm not quite sure what is going on here. I suspect a problem in how gpsd is started automatically (possibly Debian or Raspian specific?). What does seem to work is a cold restart (from power off) with the dongle attached, log in, kill and restart gpsd, and then run cgps.

GPS Babel

The Open Street-Map on their instructions for uploading GPS tracks request GPX format and recommend GPS Babel to generate this. At the time of writing the latest release is GPSBabel 1.4.4, the repository hasn't caught up yet as this gave me v1.4.3:

$ sudo apt-get install gpsbabel
...

$ gpsbabel -V

GPSBabel Version 1.4.3

Then (provided that everything was co-operating - see above), I could use the gpsd utility to switch the output to NMEA mode, capture some of that to a file, and convert it into GPX format using gpsbabel:

$ gpsctl -f -n /dev/ttyUSB0
gpsctl:SHOUT: vendor/product match with 091e:0003 not found
gpsctl:SHOUT: /dev/ttyUSB0 identified as a SiRF binary at 4800.
gpsctl:SHOUT: switching to mode NMEA.
$ cat /dev/ttyUSB0
$GPGGA,...
^C
$ cat /dev/ttyUSB0 > temp.nmea
^C
$ gpsbabel -i nmea -f temp.nmea -o gpx -F temp.gpx
$ head temp.gpx
<?xml version="1.0" encoding="UTF-8"?>
<gpx
  version="1.0"
  creator="GPSBabel - http://www.gpsbabel.org"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns="http://www.topografix.com/GPX/1/0"
  xsi:schemaLocation="http://www.topografix.com/GPX/1/0 http://www.topografix.com/GPX/1/0/gpx.xsd">
<time>2012-10-11T18:17:34Z</time>
<bounds minlat="56.xxxxxxxxx" minlon="-3.xxxxxxxxx" maxlat="56.xxxxxxxxx" maxlon="-3.xxxxxxxxx"/>
<trk>

In principle that should work with the SiRF binary format, but perhaps something is going wrong when I try to capture a random section with since the GPX file is essentially empty (valid XML, but no actual data unlike the NMEA capture above):

$ gpsctl -f /dev/ttyUSB0
gpsctl:SHOUT: vendor/product match with 091e:0003 not found
gpsctl:SHOUT: /dev/ttyUSB0 identified as a SiRF binary at 4800.
$ cat /dev/ttyUSB0 > temp.sbn
^C
$ gpsbabel -i sbn -f temp.sbn -o gpx -F temp.gpx
$ more temp.gpx
<?xml version="1.0" encoding="UTF-8"?>
<gpx
  version="1.0"
  creator="GPSBabel - http://www.gpsbabel.org"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns="http://www.topografix.com/GPX/1/0"
  xsi:schemaLocation="http://www.topografix.com/GPX/1/0 http://www.topografix.com/GPX/1/0/gpx.xsd">
<time>2012-10-11T18:25:47Z</time>
</gpx>

That was rather tortuous. But with the rough edges sorted out could work as the basis of a GPS track logger.

Update 1

Here's a link to Peter Mount's blog post using a GPS dongle and Raspberry Pi as an NTP server (Network Time Protocol), useful as a way to set the clock on a RPi as it has no internal battery like a normal PC - meaning it needs a network connection or other external system to set the time and date. It seems he is also wondering about connecting his Raspberry Pi to his telescope...

Update 2

Here's a link to David Taylor's GSP based Raspberry Pi NTP server page, incredibly detailed including how to use Pulse Per Second (PPS) for improved precision.