Category Archives: 우분투(Ubuntu)

[Arduino] Access the usb serial port on Ubuntu

You can do that by adding the pi user to the tty and dialout groups. You’ll need to do this before running the Arduino IDE.

sudo usermod -a -G tty pi
sudo usermod -a -G dialout pi

usermod: is a Linux program to manage users
-a -G: puts the user (pi) in the specified group (tty, then dialout)

Now you can run Arduino. Click Tools→Serial Port and select the serial port (most likely /dev/ttyACM0), then click Tools→Board select the type of Arduino Board you have (e.g. Uno)

[ubuntu] How to find the MAC address of a remote computer?

$ ping 192.168.0.3

$ arp -a

PING the target machine so you have made contact with it and then issue the command arp -a to view your local arp table, which will list IP addresses and their corresponding MAC addresses eg:

 arp - manipulate the system ARP cache

SYNOPSIS
       arp [-vn] [-H type] [-i if] [-a] [hostname]

       arp [-v] [-i if] -d hostname [pub]

       arp [-v] [-H type] [-i if] -s hostname hw_addr [temp]

       arp [-v] [-H type] [-i if] -s hostname hw_addr [netmask nm] pub

       arp [-v] [-H type] [-i if] -Ds hostname ifname [netmask nm] pub

       arp [-vnD] [-H type] [-i if] -f [filename]

DESCRIPTION
       Arp  manipulates or displays the kernel's IPv4 network neighbour cache. It can add entries to the table, delete one or display the current
       content.

       ARP stands for Address Resolution Protocol, which is used to find the media access control address of a network neighbour for a given IPv4
       Address.

[Arduino Wifi shield] How to upgrade Wifi shield firmware on Ubuntu

ref. http://flashgamer.com/arduino/comments/how-to-update-the-official-arduino-wifi-shield
http://arduino.cc/en/Hacking/WiFiShieldFirmwareUpgrading

Hardware: Arduino UNO rev.3, Arduino Wifi shield, usb mini cable

1. Install dfu-programmer

sudo apt-get install dfu-programmer

2. Download latest Wifi shield firmware

https://github.com/arduino/Arduino/tree/master/hardware/arduino/firmwares
또는, Aduino IDE software 에 포함된 Wifi shield 펌웨어 사용.
arduino-nightly/hardware/arduino/avr/firmwares/wifishield/binary/

3. Wifi shield 의 Power 핀과 Analog 핀 사이에 있는 점퍼 둘을 연결함

4. ArduinoWifiShield_upgrade.sh 스크립트를 실행

$ cd arduino-nightly/hardware/arduino/avr/firmwares/wifishield/scripts
–> ArduinoWifiShield_upgrade.sh 파일에서 경로수정
$ vi ArduinoWifiShield_upgrade.sh
# WIFI_FW_PATH=”/hardware/arduino/firmwares/wifishield/binary”
WIFI_FW_PATH=”/hardware/arduino/avr/firmwares/wifishield/binary”

$ sudo chmod a+x ArduinoWifiShield_upgrade.sh

- 스크립트 파일 도움말:
$ sudo ./ArduinoWifiShield_upgrade.sh -h

- 스크립트 파일 실행:
–> 옵션:
-a : Arduino IDE 설치 경로
-f : shield (Arduino WiFi Shield upgrade), all (Arduino WiFi Shield upgrade, HD WiFi module firmware)

sudo ./ArduinoWifiShield_upgrade.sh -a /home/jinny/App/arduino-nightly -f all

       Arduino WiFi Shield upgrade
=========================================
Instructions:

To access to the USB devices correctly, the dfu-programmer needs to have the root permissions.

You can upgrade the firmware of the antenna togheter with the shield firmware or only the shield firmware
if there aren't changes on the antenna firmware.

Use the '-h' parameter for help
=========================================

****Upgrade HD WiFi module firmware****

Validating...
167732 bytes used (66.05%)

Press the RESET button on the shield then type [ENTER] to upgrade the firmware of the shield..

****Upgrade WiFi Shield firmware****

Validating...
261594 bytes used (103.01%)

Done. Remove the J3 jumper and press the RESET button on the shield.
Thank you!

5. 점퍼를 연결한 핀을 제거하고 Reset 버튼을 누룸.

[ubuntu] avconv: 비디오와 오디오 컨버터

avconv is a very fast video and audio converter that can also grab from
a live audio/video source. It can also convert between arbitrary sample
rates and resize video on the fly with a high quality polyphase filter.

ref. http://manpages.ubuntu.com/manpages/precise/man1/avconv.1.html

avconv 컨버터를 사용하려면  libav-tools 패키지를 설치한다.

$ sudo  apt-get install  libav-tools

EBS Radio 교육방송 녹음하기위한 쉡스크립트

#!/bin/bash
RADIO_ADDR="rtmp://ebsandroid.nefficient.com/fmradiofamilypc/familypc1m"
RADIO_NAME="ebs_radio"

PROGRAM_NAME=$1
RECORD_MINS=$(($2 * 60))
DEST_DIR=$3

REC_DATE=`date +%Y%m%d-%H%M`
TEMP_FLV=`mktemp -u`

MP3_FILE_NAME=$PROGRAM_NAME"_"$REC_DATE.mp3

rtmpdump -r $RADIO_ADDR -B $RECORD_MINS -o $TEMP_FLV
avconv -i $TEMP_FLV -ac 2 -ab 128 -vn -y  -f mp3 $MP3_FILE_NAME

rm $TEMP_FLV

mkdir -p $DEST_DIR
mv $MP3_FILE_NAME $DEST_DIR

[Ubuntu]Recover MongoDB Data following Unexpected Shutdown

ref. http://docs.mongodb.org/manual/tutorial/recover-data-following-unexpected-shutdown/

log file:
$ tail -f /var/log/mongodb/mongodb.log

mongodb data path:
/var/lib/mongodb/

- 2가지 방법 중에 2번째 방법으로 간단히 복구
1. mongod.lock 파일 삭제:
$ sudo rm /var/lib/mongodb/mongod.lock

2. mongod 를 –repair 옵션으로 복구 시작:
$ sudo mongod –dbpath /var/lib/mongodb –repair
$ sudo chown -R mongodb:mongodb /var/lib/mongodb

3. mongodb 시작:
$ sudo service mongodb start
$ sudo service mongodb status

 

[ubuntu 12.04] reinstall grub

ubuntu server 12.04 를 부팅할 때,
grub prompt 상태에 들어가서
grub> _

더 이상 진행되지 않아 grub를 다시 설치해 문제를 해결했다.

ubuntu CD로 부팅해 복구시스템 모드로 들어가
grub를 설치함.
fdisk 로 부팅 파티션을 확인(*표시: /dev/sda1 *)

# sudo fdisk -l

# sudo mount /dev/sda1 /mnt
# sudo grub-install --boot-directory=/mnt/  /dev/sda

# sudo reboot