เนื่องจากได้รับงานด่วนๆ ให้ทดลอง usb qr-code reader กับ raspberry pi4
จึงได้ซื้อของยี่ห้อ waveshare มา
สามารถซื้อได้จากที่นี่
https://www.waveshare.com/barcode-scanner-module.htm
คู่มือ ตามนี้
https://www.waveshare.com/w/upload/archive/3/3c/20180623102926%21Barcode_Scanner_Module_User_Manual_EN.pdf
qr-code reader รุ่นนี้ สามารถอ่าน bar-code ได้ด้วย
สามารถใช้งานได้ 2 แบบ คือ แบบ usb และแบบ uart
ในที่นี้ผมเลือกใช้แบบ usb เพราะว่าหน้างาน อาจจะได้ใช้ qr-code reader 2 ตัวพร้อมกัน
และคนที่ติดตั้งก็ไม่ใช่เรา ดังนั้นต้องยืดหยุ่นให้มากที่สุดเท่าที่จะทำได้
เมื่อได้ของมาแล้ว ก็ไม่รอช้า เสียบเข้าช่อง usb ของ raspberrypi4 เลย
ตัว raspberrypi จะเห็น qr-code reader อยู่ที่ /dev/hidraw0
เราสามารถตรวจสอบว่า raspberrypi มองเห็นอุปกรณ์ตัวนี้ไหม โดยพิมพ์ ls /dev/hi* แล้วกด enter
เราสามารถเขียนโปรแกรมให้อ่านข้อมูลที่ได้จากการสแกนจากที่นี่
ซึ่งผมและทีมงานก็ได้พยายามหาข้อมูลจากอาจารย์ goo เหมือนเดิม จนไปเจอที่นี่
https://www.raspberrypi.org/forums/viewtopic.php?f=45&t=55100
ซึ่งมี code ให้อยู่ จึงได้ copy มา แล้วก็ทดสอบเลย
ก็ติดปัญหาบ้าง เช่น
1. code ที่เขาแปะไว้ คือใช้กับ python2 เราก็ต้องเรียกใช้ให้ถูกวิธี
2. code ที่ได้มา มีการ map ค่าที่ได้ ต่างกับ Hardware ที่เรามี ก็ต้องมา map ใหม่ ยุ่งยากเล็กน้อย
สุดท้ายแล้ว ก็ต้องปรับ code จนออกมาเป็นเวอร์ชั่นที่ใช้ได้ ดังนี้
import sys
hid = { 4: 'a', 5: 'b', 6: 'c', 7: 'd', 8: 'e', 9: 'f', 10: 'g', 11: 'h', 12: 'i', 13: 'j', 14: 'k', 15: 'l', 16: 'm', 17: 'n', 18: 'o', 19: 'p', 20: 'q', 21: 'r', 22: 's', 23: 't', 24: 'u', 25: 'v', 26: 'w', 27: 'x', 28: 'y', 29: 'z', 30: '!', 31: '@', 32: '#', 33: '$', 34: '%', 35: '^', 36: '&', 37: '*', 38: '(', 39: ')', 44: ' ', 45: '_', 46: '+', 47: '{', 48: '}', 49: '|', 51: ':' , 52: '"', 53: '~', 54: '<', 55: '>', 56: '?' }
hid2 = { 4: 'A', 5: 'B', 6: 'C', 7: 'D', 8: 'E', 9: 'F', 10: 'G', 11: 'H', 12: 'I', 13: 'J', 14: 'K', 15: 'L', 16: 'M', 17: 'N', 18: 'O', 19: 'P', 20: 'Q', 21: 'R', 22: 'S', 23: 'T', 24: 'U', 25: 'V', 26: 'W', 27: 'X', 28: 'Y', 29: 'Z', 30: '1', 31: '2', 32: '3', 33: '4', 34: '5', 35: '6', 36: '7', 37: '8', 38: '9', 39: '0', 44: ' ', 45: '-', 46: '=', 47: '[', 48: ']', 49: '\\', 51: ';' , 52: '\'', 53: '~', 54: ',', 55: '.', 56: '/' }
fp = open('/dev/hidraw0', 'rb')
ss = ""
shift = False
done = False
d = 0
first_char = 0
while not done:
## Get the character from the HID
buffer = fp.read(8)
for c in buffer:
d = d+1
if c > 0:
if int((c)) == 57:
print ("Start/Stop Package")
else:
## 40 is carriage return which signifies
## we are done looking for characters
if int((c)) == 40:
if shift:
ss += '3'
done = True
break;
## If we are shifted then we have to
## use the hid2 characters.
if shift:
## If it is a '2' then it is the shift key
if int((c)) == 32 :
ss += '#'
shift = False
## if not a 2 then lookup the mapping
else:
if d == first_char+16:
ss+= '3'
shift = False
ss += hid2[int(c)]
else:
ss += hid[ int((c)) ]
shift = False
## If we are not shifted then use
## the hid characters
else:
## If it is a '2' then it is the shift key
if int((c)) == 32 :
shift = True
first_char = d
## if not a 2 then lookup the mapping
else:
ss += hid2[ int((c)) ]
print (ss)
เมื่อ save โปรแกรมแล้ว ให้เปลี่ยน permission ด้วย
sudo chmod 766 ชื่อโปรแกรม.py
ตอนเรียกใช้ ให้เรียกใช้แบบนี้
sudo python3 ชื่อโปรแกรม.py
ต่อมา
เราต้องการ QR-Code ตัวอย่าง ในการอ่านข้อมูล ก็ให้หาเวปที่สร้าง QR-Code ได้ ซึ่งมีอยู่มากมาย
ยกตัวอย่างเช่น https://www.the-qrcode-generator.com/ หรือ
https://th.qr-code-generator.com/
เมื่อเราสร้าง QR-Code ได้แล้ว ก็ลอง scan ได้เลย
ค่าที่อ่านได้ จะต้องเหมือนกันกับที่เราสร้างในเวป
น่าจะเป็นประโยชน์ต่อผู้สนใจนะครับ
blog นี้จะกล่าวถึง Raspberry Pi Raspbian เป็นหลัก โดยจะอธิบายทั้งการใช้ windows และ Linux ในการเชื่อมต่อ วิธีอ่าน : ให้เริ่มอ่านตั้งแต่หัวข้อแรกๆขึ้นมา(ให้ดูที่ "คลังบทความ" ทางด้านขวามือ จะมี วัน-เวลา ไล่เรียงอยู่) ไม่งั้นอาจจะงงได้ สำหรับมือใหม่ หรือท่านใดที่ไม่เข้าใจ สามารถ mail มาถามกันได้ครับ ที่ kongimi1980@gmail.com หรือที่ line : 0814282425
วันศุกร์ที่ 22 พฤษภาคม พ.ศ. 2563
วันพฤหัสบดีที่ 9 เมษายน พ.ศ. 2563
การทำ qt cross compile raspberry pi4
ถ้าต้องการทำ Cross Compile RaspberryPi4 ให้ทำตามนี้https://mechatronicsblog.com/cross-compile-and-deploy-qt-5-12-for-raspberry-pi/
(ที่มา https://forum.qt.io/topic/109885/cross-compile-qt-5-12-5-for-raspberry-pi-4/7)
1.sudo nano /etc/default/keyboard ให้เปลี่ยนจาก "gb" ไปเป็น "us" เพื่อทำให้ keyboard เป็น us
2.sudo reboot
3.sudo raspi-conig
3.1 change password
3.2 change Time-Zone ให้เป็น Asia, Bangkok
3.3 Interface option
3.3.1 Enable I2C
3.3.2 Enable SSH
4.sudo nano /boot/config.txt
4.1 uncomment hdmi_force_hotplug=1
4.2 uncomment hdmi_group=1, hdmi_mode=16
5.sudo apt-get update
6.sudo apt-get upgrade
7.sudo apt-get install wiringpi
8.cd /temp
9.wget https://project-downloads.drogon.net/wiringpi-latest.deb
10.sudo dpkg -i wiringpi-latest.deb
11.check ด้วยคำสั่ง gpio -v และ gpio readall
12.sudo nano /etc/apt/sources.list
uncomment the deb-src line in the /etc/apt/sources.list
4บรรทัดต่อไปนี้ ให้เปลี่ยน raspberrypi_ip เป็น ip ของ raspberry pi ที่เราใช้อยู่
เพื่อเป็นการเช็คว่าไฟล์ที่ download มา สมบูรณ์หรือไม่ ให้ทำนี้
cd qt-raspberrypi-configuration && make install DESTDIR=~/raspi/qt-everywhere-src-5.12.7
================================================
./configure -release -opengl es2 -device linux-rasp-pi-g++ -device-option CROSS_COMPILE=~/raspi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/arm-linux-gnueabihf- -sysroot ~/raspi/sysroot -opensource -confirm-license -skip qtwayland -skip qtlocation -skip qtscript -make libs -prefix /usr/local/qt5pi -extprefix ~/raspi/qt5pi -hostprefix ~/raspi/qt5 -no-use-gold-linker -v -no-gbm
จริงๆแล้วควรจะต้องแก้ไขเป็น -device linux-rasp-pi-vc4-g++ เนื่องจากบอร์ดของเราเป็น rpi4 แต่ทำแล้วใช้ไม่ได้ จึงต้องเป็น -device linux-rasp-pi-g++ ตามเดิม
ตัวอย่างที่แก้ไขแล้ว ที่ใช้ไม่ได้
./configure -release -opengl es2 -device linux-rasp-pi-vc4-g++ -device-option CROSS_COMPILE=~/raspi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/arm-linux-gnueabihf- -sysroot ~/raspi/sysroot -opensource -confirm-license -skip qtwayland -skip qtlocation -skip qtscript -make libs -prefix /usr/local/qt5pi -extprefix ~/raspi/qt5pi -hostprefix ~/raspi/qt5 -no-use-gold-linker -v -no-gbm
หลังจาก ./config ...... เสร็จแล้ว ให้เช็คว่า config สมบูรณ์ไหม โดยให้เปิดไฟล์ config.summary
ต้องเป็นตามนี้
แล้วก็ make install
rsync -avz qt5pi pi@raspberrypi_ip:/usr/local
ให้เปลี่ยน raspberrypi_ip เป็น ip ของ raspberry pi
แล้วก็ลง qt ที่เครื่อง linux ของเรา ตามนี้ https://www.qt.io/download
ให้เลือก download for open source users โดยคลิกที่ go open source
ลงไปด้านล่างของเวป click download the qt online installer แล้วก็คลิก download
จะมี pop-up ให้ download qt-unified-linux-x64-3.2.2-online.run ขึ้นมา ก็ให้กด save file
- chmod +x qt-unified-linux-x64-3.2.2-online.run
- ./qt-unified-linux-x64-3.2.2-online.run
จะมีอยู่ช่วงนึงจะให้เลือกว่าเราจะลงเวอร์ชั่นไหน ในที่นี้เลือก 5.12.7 เหมือนกับกับที่ทำตั้งค่า cross compile
แล้วก็รอ download กันยาวๆไป
เมื่อลงโปรแกรมเสร็จแล้ว ก็ให้เปิดโปรแกรมขึ้นมา
ไปที่ tools, options, device section(มองหาที่ด้านซ้าย), device tab(มองหาที่กลางบน), แล้วกด add ที่ด้านขวามือ
แล้วเลือกเป็น general linux device แล้ว click start wizard
name : Raspberry Pi
ip : 192.168.1.xx (ตาม ip ของ raspberry pi ของเรา)
user name : pi
จะมีให้สร้าง key deployment ให้คลิกที่ create new key pair
ขั้นตอนนี้ต้องเปิด Raspberry Pi ไว้ด้วย เพราะจะมีการทดสอบระหว่าง qt ของเครื่องคอมฯ กับ RPi
คลิก Generate and save key pair
ไปที่ kit section, compiler tab, แล้วกด Add
GCC, C
ในช่อง compiler path ให้ใส่ ~/raspi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/arm-linux-gnueabihf/bin/gcc
กด Add แล้วเลือก GCC, C++
ในช่อง compiler path ให้ใส่ ~/raspi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/arm-linux-gnueabihf/bin/c++
ไปที่ Debugger tab แล้วกด Add
ในช่อง path ให้ใส่ ~/raspi/tools/arm-bcm2708/arm-rpi-4.9.3-linux-gnueabihf/bin/arm-linux-gnueabihf-gdb
ไปที่ Qt version tab แล้วกด Add ให้ตั้ง qmake path ไปที่ ~/raspi/qt5/bin/qmake
สุดท้าย ไปที่ Kits tab, กด Add แล้วตั้งชื่อ และเลือก icon ตามใจ แล้ว configure ค่าต่างๆ ตามนี้
หลังจากนี้ ให้ลองสร้าง project ใหม่ จะมีตอนที่ให้เลือก Kits ก็เลือก Raspberry Pi ที่เราสร้างไว้
แล้วก็ลองเขียนโปรแกรมได้เลย
Enjoy!
(ที่มา https://forum.qt.io/topic/109885/cross-compile-qt-5-12-5-for-raspberry-pi-4/7)
ที่ raspberry pi
หลังจากทำ raspbian ลง sd-card แล้ว ให้ทำ headless ssh ตาม step 3, ตามเวปนี้ https://hackernoon.com/raspberry-pi-headless-install-462ccabd75d01.sudo nano /etc/default/keyboard ให้เปลี่ยนจาก "gb" ไปเป็น "us" เพื่อทำให้ keyboard เป็น us
2.sudo reboot
3.sudo raspi-conig
3.1 change password
3.2 change Time-Zone ให้เป็น Asia, Bangkok
3.3 Interface option
3.3.1 Enable I2C
3.3.2 Enable SSH
4.sudo nano /boot/config.txt
4.1 uncomment hdmi_force_hotplug=1
4.2 uncomment hdmi_group=1, hdmi_mode=16
5.sudo apt-get update
6.sudo apt-get upgrade
7.sudo apt-get install wiringpi
8.cd /temp
9.wget https://project-downloads.drogon.net/wiringpi-latest.deb
10.sudo dpkg -i wiringpi-latest.deb
11.check ด้วยคำสั่ง gpio -v และ gpio readall
12.sudo nano /etc/apt/sources.list
uncomment the deb-src line in the /etc/apt/sources.list
- sudo apt-get update
- sudo apt-get build-dep qt4-x11
- sudo apt-get build-dep libqt5gui5
- sudo apt-get install libudev-dev libinput-dev libts-dev libxcb-xinerama0-dev libxcb-xinerama0
- sudo mkdir /usr/local/qt5pi
- sudo chown pi:pi /usr/local/qt5pi
ที่ computer linux
sudo apt-get install python- mkdir ~/raspi
- cd ~/raspi
- git clone https://github.com/raspberrypi/tools
4บรรทัดต่อไปนี้ ให้เปลี่ยน raspberrypi_ip เป็น ip ของ raspberry pi ที่เราใช้อยู่
- rsync -avz pi@raspberrypi_ip:/lib sysroot
- rsync -avz pi@raspberrypi_ip:/usr/include sysroot/usr
- rsync -avz pi@raspberrypi_ip:/usr/lib sysroot/usr
- rsync -avz pi@raspberrypi_ip:/opt/vc sysroot/opt
- wget https://raw.githubusercontent.com/riscv/riscv-poky/master/scripts/sysroot-relativelinks.py
- chmod +x sysroot-relativelinks.py
- ./sysroot-relativelinks.py sysroot
wget http://download.qt.io/official_releases/qt/5.12/5.12.7/single/qt-everywhere-src-5.12.7.tar.xzที่มา https://www.tal.org/tutorials/building-qt-512-raspberry-pi
เพื่อเป็นการเช็คว่าไฟล์ที่ download มา สมบูรณ์หรือไม่ ให้ทำนี้
md5sum qt-everywhere-src-5.12.7.tar.xz
ควรจะมีผลลลัพธ์ตามนี้
ce2c5661c028b9de6183245982d7c120 qt-everywhere-src-5.12.7.tar.xz
- tar xvf qt-everywhere-src-5.12.7.tar.xz
- cd qt-everywhere-src-5.12.7
sudo apt-get install build-essential
=========== ตรงนี้ไม่แน่ใจว่าต้องทำหรือไม่ ======================
git clone https://github.com/oniongarlic/qt-raspberrypi-configuration.git
cd qt-raspberrypi-configuration && make install DESTDIR=../qt-everywhere-src-5.12.7ตรงนี้ให้แก้เป็น
cd qt-raspberrypi-configuration && make install DESTDIR=~/raspi/qt-everywhere-src-5.12.7
================================================
./configure -release -opengl es2 -device linux-rasp-pi-g++ -device-option CROSS_COMPILE=~/raspi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/arm-linux-gnueabihf- -sysroot ~/raspi/sysroot -opensource -confirm-license -skip qtwayland -skip qtlocation -skip qtscript -make libs -prefix /usr/local/qt5pi -extprefix ~/raspi/qt5pi -hostprefix ~/raspi/qt5 -no-use-gold-linker -v -no-gbm
จริงๆแล้วควรจะต้องแก้ไขเป็น -device linux-rasp-pi-vc4-g++ เนื่องจากบอร์ดของเราเป็น rpi4 แต่ทำแล้วใช้ไม่ได้ จึงต้องเป็น -device linux-rasp-pi-g++ ตามเดิม
ตัวอย่างที่แก้ไขแล้ว ที่ใช้ไม่ได้
./configure -release -opengl es2 -device linux-rasp-pi-vc4-g++ -device-option CROSS_COMPILE=~/raspi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/arm-linux-gnueabihf- -sysroot ~/raspi/sysroot -opensource -confirm-license -skip qtwayland -skip qtlocation -skip qtscript -make libs -prefix /usr/local/qt5pi -extprefix ~/raspi/qt5pi -hostprefix ~/raspi/qt5 -no-use-gold-linker -v -no-gbm
หลังจาก ./config ...... เสร็จแล้ว ให้เช็คว่า config สมบูรณ์ไหม โดยให้เปิดไฟล์ config.summary
ต้องเป็นตามนี้
- Build options:
- ......
- QPA backends:
- ......
- EGLFS .................................. yes
- EGLFS details:
- ......
- EGLFS Raspberry Pi ................... yes
แล้วก็ make install
rsync -avz qt5pi pi@raspberrypi_ip:/usr/local
ให้เปลี่ยน raspberrypi_ip เป็น ip ของ raspberry pi
แล้วก็ลง qt ที่เครื่อง linux ของเรา ตามนี้ https://www.qt.io/download
ให้เลือก download for open source users โดยคลิกที่ go open source
ลงไปด้านล่างของเวป click download the qt online installer แล้วก็คลิก download
จะมี pop-up ให้ download qt-unified-linux-x64-3.2.2-online.run ขึ้นมา ก็ให้กด save file
- chmod +x qt-unified-linux-x64-3.2.2-online.run
- ./qt-unified-linux-x64-3.2.2-online.run
จะมีอยู่ช่วงนึงจะให้เลือกว่าเราจะลงเวอร์ชั่นไหน ในที่นี้เลือก 5.12.7 เหมือนกับกับที่ทำตั้งค่า cross compile
แล้วก็รอ download กันยาวๆไป
เมื่อลงโปรแกรมเสร็จแล้ว ก็ให้เปิดโปรแกรมขึ้นมา
ไปที่ tools, options, device section(มองหาที่ด้านซ้าย), device tab(มองหาที่กลางบน), แล้วกด add ที่ด้านขวามือ
แล้วเลือกเป็น general linux device แล้ว click start wizard
name : Raspberry Pi
ip : 192.168.1.xx (ตาม ip ของ raspberry pi ของเรา)
user name : pi
จะมีให้สร้าง key deployment ให้คลิกที่ create new key pair
ขั้นตอนนี้ต้องเปิด Raspberry Pi ไว้ด้วย เพราะจะมีการทดสอบระหว่าง qt ของเครื่องคอมฯ กับ RPi
คลิก Generate and save key pair
ไปที่ kit section, compiler tab, แล้วกด Add
GCC, C
ในช่อง compiler path ให้ใส่ ~/raspi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/arm-linux-gnueabihf/bin/gcc
กด Add แล้วเลือก GCC, C++
ในช่อง compiler path ให้ใส่ ~/raspi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/arm-linux-gnueabihf/bin/c++
ไปที่ Debugger tab แล้วกด Add
ในช่อง path ให้ใส่ ~/raspi/tools/arm-bcm2708/arm-rpi-4.9.3-linux-gnueabihf/bin/arm-linux-gnueabihf-gdb
ไปที่ Qt version tab แล้วกด Add ให้ตั้ง qmake path ไปที่ ~/raspi/qt5/bin/qmake
สุดท้าย ไปที่ Kits tab, กด Add แล้วตั้งชื่อ และเลือก icon ตามใจ แล้ว configure ค่าต่างๆ ตามนี้
- Device type: Generic Linux Device
- Device: Raspberry Pi (defaut for Generic Linux)
- Sysroot: ~/raspi/sysroot
- Compiler C: GCC (Raspberry Pi)
- Compiler C++: GCC (Raspberry Pi)
- Debugger: GDB (Raspberry Pi)
- Qt version: Qt 5.12.7 (Raspberry Pi)
หลังจากนี้ ให้ลองสร้าง project ใหม่ จะมีตอนที่ให้เลือก Kits ก็เลือก Raspberry Pi ที่เราสร้างไว้
แล้วก็ลองเขียนโปรแกรมได้เลย
Enjoy!
วันพฤหัสบดีที่ 19 มีนาคม พ.ศ. 2563
check program running, crontab shell script
หากเราต้องการตรวจสอบว่า โปรแกรมที่เราเขียนนั้น ยังทำงานอยู่หรือไม่ ให้ทำดังนี้
pgrep ตามด้วยชื่อโปรแกรม เช่น pgrep TagAgent
ก็จะได้เลข PID ออกมา ซึ่งเป็นเลข process ของโปรแกรม
จำเป็นต้องศึกษาการใช้งานสักเล็น้อย ก่อนใช้งาน
สร้างไฟล์ขึ้นมาโดยพิมพ์ nano check_process.sh
#!/bin/bash
sudo rm /tmp/TagAgent.pid
pidof TagAgent >> /tmp/TagAgent.pid
nano monitor-process.sh
#!/bin/bash
sudo rm /tmp/TagAgent.pid
sudo pidof TagAgent >> /tmp/TagAgent.pid
declare -i x=0
while IFS= read -r line; do
if [ $line != "" ]
then
echo "Text: $line"
x=$((x+1))
else
echo "No text"
fi
done < /tmp/TagAgent.pid
if [ $x == 0 ]
then
cd /home/pi/TagAgent
sudo ./TagAgent &
else
echo "run"
fi
เมื่อเราสร้างไฟล์ Script แล้ว ต้องทำให้ไฟล์นี้รันได้
sudo chmod +x monitor-process.sh
และก็ต้องตั้งเวลาให้ไฟล์ตัวนี้รันทุกๆ 1 นาที
เราสามารถทำได้โดยใช้ Crontab ดังนี้
พิมพ์ crontab -e
บรรทัดล่างสุด ให้เพิ่ม
* * * * * /home/pi/monitor-process.sh
กด control + o, control+x
sudo /etc/init.d/cron restart
ในรูปนี้พลาดไปอย่างนึง คือมันจะ reboot ทุกๆนาทีตอนตี 2 หมายความว่า 2.00 น., 2.01 น., 2.02 น. ... จะ reboot ตลอดทุกนาที จนกว่าจะถึงเวลาตี 3
ดังนั้นถ้าจะแก้ให้ถูกต้อง คือ reboot แค่ครั้งเดียวตอนตี 2 จะต้องแก้เป็น
0 2 * * * sudo reboot
และจากการทดสอบใช้จริง การใช้ pidof จาก shell script (วิธีที่2) มันจะมีการเช็คพลาดบางครั้ง
ดังนั้น จึงไม่แนะนำให้ใช้ วิธีการนี้ครับ
จบ
ที่มา
https://stackoverflow.com/questions/10929453/read-a-file-line-by-line-assigning-the-value-to-a-variable
https://linuxize.com/post/how-to-remove-files-and-directories-using-linux-command-line/
https://bash.cyberciti.biz/guide/Create_an_integer_variable
https://askubuntu.com/questions/682913/how-to-write-shell-script-to-start-some-programs
วิธีที่1 Terminal
เปิด terminal แล้วพิมพ์pgrep ตามด้วยชื่อโปรแกรม เช่น pgrep TagAgent
ก็จะได้เลข PID ออกมา ซึ่งเป็นเลข process ของโปรแกรม
วิธีที่2 Shell script (ไม่แนะนำ เนื่องจากพลาดได้บางครั้ง)
ในการเขียน shell script การใช้เครื่องหมายต่างๆ, การเว้นวรรค มีผลต่อการเขียนโปรแกรมจำเป็นต้องศึกษาการใช้งานสักเล็น้อย ก่อนใช้งาน
สร้างไฟล์ขึ้นมาโดยพิมพ์ nano check_process.sh
#!/bin/bash
sudo rm /tmp/TagAgent.pid
pidof TagAgent >> /tmp/TagAgent.pid
while IFS= read -r line; do
echo "Text read from file: $line"
done < /tmp/TagAgent.pid
Shell script ตรวจสอบโปรแกรม
ถ้าเราต้องการตรวจสอบว่าโปรแกรมรันอยู่หรือไม่ แล้วถ้าไม่รัน ก็สั่งให้เปิดโปรแกรม ให้ทำดังนี้nano monitor-process.sh
#!/bin/bash
sudo rm /tmp/TagAgent.pid
sudo pidof TagAgent >> /tmp/TagAgent.pid
declare -i x=0
while IFS= read -r line; do
if [ $line != "" ]
then
echo "Text: $line"
x=$((x+1))
else
echo "No text"
fi
done < /tmp/TagAgent.pid
if [ $x == 0 ]
then
cd /home/pi/TagAgent
sudo ./TagAgent &
else
echo "run"
fi
เมื่อเราสร้างไฟล์ Script แล้ว ต้องทำให้ไฟล์นี้รันได้
sudo chmod +x monitor-process.sh
และก็ต้องตั้งเวลาให้ไฟล์ตัวนี้รันทุกๆ 1 นาที
เราสามารถทำได้โดยใช้ Crontab ดังนี้
พิมพ์ crontab -e
บรรทัดล่างสุด ให้เพิ่ม
* * * * * /home/pi/monitor-process.sh
กด control + o, control+x
sudo /etc/init.d/cron restart
ในรูปนี้พลาดไปอย่างนึง คือมันจะ reboot ทุกๆนาทีตอนตี 2 หมายความว่า 2.00 น., 2.01 น., 2.02 น. ... จะ reboot ตลอดทุกนาที จนกว่าจะถึงเวลาตี 3
ดังนั้นถ้าจะแก้ให้ถูกต้อง คือ reboot แค่ครั้งเดียวตอนตี 2 จะต้องแก้เป็น
0 2 * * * sudo reboot
และจากการทดสอบใช้จริง การใช้ pidof จาก shell script (วิธีที่2) มันจะมีการเช็คพลาดบางครั้ง
ดังนั้น จึงไม่แนะนำให้ใช้ วิธีการนี้ครับ
จบ
ที่มา
https://stackoverflow.com/questions/10929453/read-a-file-line-by-line-assigning-the-value-to-a-variable
https://linuxize.com/post/how-to-remove-files-and-directories-using-linux-command-line/
https://bash.cyberciti.biz/guide/Create_an_integer_variable
https://askubuntu.com/questions/682913/how-to-write-shell-script-to-start-some-programs
วันศุกร์ที่ 7 กุมภาพันธ์ พ.ศ. 2563
RaspberryPi Connect bluetooth printer ทำยังไง ตอนที่2
จะเป็นการลง Driver ที่ตัว CUPS
ถ้าเราเคยลง driver ไว้ก่อนหน้านี้แล้ว ให้เอาออกก่อน 2 ไฟล์ ดังนี้
/usr/share/cups/model/Custom/
MY3 raster file from /usr/lib/cups/filter/.
เมื่อ download มาแล้ว ให้นำไปวางไว้ใน raspberry pi แล้วแตกไฟล์
tar -xvzf /path/to/yourfile.tgz
เมื่อแตกไฟล์เสร็จแล้ว ให้รัน MY3_CUPSDrv-200.sh.
1) sudo apt-get install bluez-cups
2) when you add printer from Cups WebPage, add the printer as "AppSocket"
3) in connection box write "bluetooth://BTADDRESSwithoutcolumns/spp"
if the BT Address is 00:80:E1:BA:D4:C3, then you have to write
bluetooth://0080E1BAD4C3/spp
แต่เราต้องรู้เลข Bluetooth ก่อน ตามนี้
4)ใส่รายละเอียดต่างๆ
5)เลือกยี่ห้อ printer
6)เลือก Model
7)Set Default
8)Print test page
ตัวอย่าง code python ในการสั่ง print รูป
import cups
conn = cups.Connection()
printers = conn.getPrinters()
for printer in printers:
print printer,printers[printer]["device-uri"]
printer_name = 'MY3'
file = "/home/pi/DriverPrinterCustom/VKP80III_CUPSDrv-202-PKG/scorpion.png"
conn.printFile(printer_name,file,"PDF Print",{})
ที่มา
https://unix.stackexchange.com/questions/223397/cups-does-not-recognize-bluetooth-receipt-printer
https://bbs.archlinux.org/viewtopic.php?id=88250
วันอังคารที่ 21 มกราคม พ.ศ. 2563
RaspberryPi connect bluetooth printer ทำยังไง
ในการใช้ Raspberry Pi ติดต่อกับ Bluetooth printer มีสิ่งที่ต้องทำหลักๆ ดังนี้
1.ติดตั้ง bluetooth
2.software python
ในที่นี้ Address ของ Bluetooth Custom printer รุ่น MY3 คือ 00:80:E1:BA:D4:C3
sudo nano test_print.py
import bluetooth
bd_addr = "00:80:E1:BA:D4:C3"
port = 1
sock = bluetooth.BluetoothSocket( bluetooth.RFCOMM )
sock.connect((bd_addr, port))
data = [0x1D,0x70,0x00,0x00,0x0A,0x0A]
for i in range(0,6):
sock.send(chr(data[i]))
sock.close()
กด Control + "o", enter, Contrl + "x"
สั่งรันโปรแกรม
python test_print.py
ซึ่งได้ผลลัพธ์ แบบนี้
ที่ทำมานี้ คือสั่ง print แบบใช้ command ส่งเข้าไปที่เครื่อง จำเป็นที่จะต้องอ่าน manual ของเครื่องว่าต้องส่งอะไรเข้าไปที่เครื่อง
อธิบายเกี่ยวกับคำสั่ง
0x1D,0x70,0x00,0x00
0x1D,0x70 หมายถึง ให้ปรินท์โลโก้
0x00 หมายถึง ภาพที่0
0x00 หมายถึง ขนาดของรูปภาพ โดยถ้าเปลี่ยนเป็นเลขอื่น มีความหมายดังนี้
0 = normal
1 = double width
2 = double height
3 = double width and double height
ที่มา
https://www.cnet.com/how-to/how-to-setup-bluetooth-on-a-raspberry-pi-3/
https://kaebmoo.wordpress.com/2017/06/26/bluetooth-raspberry-pi/
ให้ดูตรงที่ ไม่ต้อง compile เอง
https://www.youtube.com/watch?v=He-3-zLgVMM ประมาณนาทีที่ 7 เป็นต้นไป
https://www.cnet.com/how-to/how-to-setup-bluetooth-on-a-raspberry-pi-3/
https://www.programcreek.com/python/example/19860/bluetooth.RFCOMM // อันนี้ ok
http://pages.iu.edu/~rwisman/c490/html/pythonandbluetooth.htm
https://www.raspberrypi.org/forums/viewtopic.php?t=232626
http://mattrichardson.com/Raspberry-Pi-Wireless-Photo-Printing/
1.ติดตั้ง bluetooth
2.software python
1.ติดตั้ง Bluetooth
sudo apt-get update sudo apt-get install pi-bluetoothsudo apt-get install bluetooth bluezsudo apt-get install python-bluezsudo hciconfig hci0 piscansudo hciconfig hci0 name 'Device Name' // change Device Namesudo python /usr/share/doc/python-bluez/examples/simple/inquiry.pyเพื่อดูว่า ตอนนี้ raspberry pi ของเรา มองเห็น Bluetooth Custom printer รุ่น MY3 หรือยัง ถ้าเห็นแล้ว จะขึ้นแบบนี้ในที่นี้ Address ของ Bluetooth Custom printer รุ่น MY3 คือ 00:80:E1:BA:D4:C3
2.Software python
เราจะลองส่งคำสั่งให้ปรินท์ Logo หมายเลข 0 ที่มีอยู่ในเครื่องอยู่แล้ว ออกมาsudo nano test_print.py
import bluetooth
bd_addr = "00:80:E1:BA:D4:C3"
port = 1
sock = bluetooth.BluetoothSocket( bluetooth.RFCOMM )
sock.connect((bd_addr, port))
data = [0x1D,0x70,0x00,0x00,0x0A,0x0A]
for i in range(0,6):
sock.send(chr(data[i]))
sock.close()
กด Control + "o", enter, Contrl + "x"
สั่งรันโปรแกรม
python test_print.py
ซึ่งได้ผลลัพธ์ แบบนี้
ที่ทำมานี้ คือสั่ง print แบบใช้ command ส่งเข้าไปที่เครื่อง จำเป็นที่จะต้องอ่าน manual ของเครื่องว่าต้องส่งอะไรเข้าไปที่เครื่อง
อธิบายเกี่ยวกับคำสั่ง
0x1D,0x70,0x00,0x00
0x1D,0x70 หมายถึง ให้ปรินท์โลโก้
0x00 หมายถึง ภาพที่0
0x00 หมายถึง ขนาดของรูปภาพ โดยถ้าเปลี่ยนเป็นเลขอื่น มีความหมายดังนี้
0 = normal
1 = double width
2 = double height
3 = double width and double height
ที่มา
https://www.cnet.com/how-to/how-to-setup-bluetooth-on-a-raspberry-pi-3/
https://kaebmoo.wordpress.com/2017/06/26/bluetooth-raspberry-pi/
ให้ดูตรงที่ ไม่ต้อง compile เอง
https://www.youtube.com/watch?v=He-3-zLgVMM ประมาณนาทีที่ 7 เป็นต้นไป
https://www.cnet.com/how-to/how-to-setup-bluetooth-on-a-raspberry-pi-3/
https://www.programcreek.com/python/example/19860/bluetooth.RFCOMM // อันนี้ ok
http://pages.iu.edu/~rwisman/c490/html/pythonandbluetooth.htm
https://www.raspberrypi.org/forums/viewtopic.php?t=232626
http://mattrichardson.com/Raspberry-Pi-Wireless-Photo-Printing/
วันอังคารที่ 7 มกราคม พ.ศ. 2563
linux python print picture to Custom Printer VKP80III
วันนี้ผมต้องการ print รูป ออกมาทางเครื่อง Custom Printer VKP80III เป็น printer คุณภาพดีจากประเทศ Italy
ซึ่งต้องลงโปรแกรม CUPS และ Driver เสียก่อน มีขั้นตอนดังนี้
เมื่อลง Driver เสร็จแล้ว ก็เข้าสูกระบวนการทาง software
เราต้อง convert รูป ให้เป็น pdf ก่อน จึงจะสั่งพิมพ์ที่เครื่อง VKP80III ได้
2.ลงโปรแกรม impage magick ก่อน โดยพิมพ์ sudo apt-get install imagemagick
3.สั่ง convert รูปให้เป็น pdf โดยใช้คำสั่งดังนี้ convert -density 300 mypic.png -compress JPEG mypic.pdf
เราก็จะได้ mypic.pdf ออกมา
nano test_print.py
import cups
conn = cups.Connection()
printers = conn.getPrinters()
for printer in printers:
print printer, printers[printer]["device-uri"]
printer_name = printers.keys()[0]
file = "/home/pi/mypic.pdf"
conn.printFile(printer_name,file,"PDF Print",{})
พอดีได้ทราบมาทีหลังว่า สามารถ print ภาพได้เลย ไม่ต้อง convert เป็น pdf ก่อน แต่ต้อง configure ที่ CUPS ก่อน ดังนี้
1.เปิด Browser เข้าไปที่ 192.168.1.xx:631
2.เข้าเมนู Printer ==> Administration ==> Set Default Options
3.เลือก Halftoning Algolithm ให้เป็น Standard
4.กด Set Default Oprions เป็นอันจบขั้นตอนนี้
ในส่วนของ Software ก็แก้ไขเล็กน้อย แค่เปลี่ยนชื่อ file เฉยๆ ก็ print ได้เลย
file = "/home/pi/mypic.png"
ที่มา
https://www.raspberrypi.org/forums/viewtopic.php?t=180370
https://stackoverflow.com/questions/12723818/print-to-standard-printer-from-python
https://smallbusiness.chron.com/sending-things-printer-python-58655.html
เราสามารถสั่ง print โดยใช้คำสั่งใน command line ดังนี้
lp ชื่อไฟล์ -d ชื่อเครื่อง
https://www.techradar.com/how-to/computing/how-to-turn-the-raspberry-pi-into-a-wireless-printer-server-1312717/2
https://www.raspberrypi.org/forums/viewtopic.php?t=180370
https://www.youtube.com/watch?v=MoCQ-6YTj5o
ซึ่งต้องลงโปรแกรม CUPS และ Driver เสียก่อน มีขั้นตอนดังนี้
เมื่อลง Driver เสร็จแล้ว ก็เข้าสูกระบวนการทาง software
เราต้อง convert รูป ให้เป็น pdf ก่อน จึงจะสั่งพิมพ์ที่เครื่อง VKP80III ได้
ลงโปรแกรม imagemagick
1.sudo apt-get udpate2.ลงโปรแกรม impage magick ก่อน โดยพิมพ์ sudo apt-get install imagemagick
3.สั่ง convert รูปให้เป็น pdf โดยใช้คำสั่งดังนี้ convert -density 300 mypic.png -compress JPEG mypic.pdf
เราก็จะได้ mypic.pdf ออกมา
Python Software
จากนั้นเราก็สั่งให้พิพม์ไปที่เครื่อง VKP80III ดังนี้nano test_print.py
import cups
conn = cups.Connection()
printers = conn.getPrinters()
for printer in printers:
print printer, printers[printer]["device-uri"]
printer_name = printers.keys()[0]
file = "/home/pi/mypic.pdf"
conn.printFile(printer_name,file,"PDF Print",{})
พอดีได้ทราบมาทีหลังว่า สามารถ print ภาพได้เลย ไม่ต้อง convert เป็น pdf ก่อน แต่ต้อง configure ที่ CUPS ก่อน ดังนี้
1.เปิด Browser เข้าไปที่ 192.168.1.xx:631
2.เข้าเมนู Printer ==> Administration ==> Set Default Options
3.เลือก Halftoning Algolithm ให้เป็น Standard
4.กด Set Default Oprions เป็นอันจบขั้นตอนนี้
ในส่วนของ Software ก็แก้ไขเล็กน้อย แค่เปลี่ยนชื่อ file เฉยๆ ก็ print ได้เลย
file = "/home/pi/mypic.png"
ที่มา
https://www.raspberrypi.org/forums/viewtopic.php?t=180370
https://stackoverflow.com/questions/12723818/print-to-standard-printer-from-python
https://smallbusiness.chron.com/sending-things-printer-python-58655.html
เราสามารถสั่ง print โดยใช้คำสั่งใน command line ดังนี้
lp ชื่อไฟล์ -d ชื่อเครื่อง
https://www.techradar.com/how-to/computing/how-to-turn-the-raspberry-pi-into-a-wireless-printer-server-1312717/2
https://www.raspberrypi.org/forums/viewtopic.php?t=180370
https://www.youtube.com/watch?v=MoCQ-6YTj5o
raspberry pi ติดตั้งเครื่องปรินท์ VKP80III Custom Printer จาก Italy
หากเราต้องการติดตั้งเครื่องปรินท์ ให้กับ RaspberryPi มีสิ่งที่ต้องทำหลักๆอยู่ 3 อย่าง คือ
1.ติดตั้งโปรแกรม CUPS
2.Download และ แตกไฟล์ Driver
3.ติดตั้ง Driver ที่ CUPS
1.sudo apt install dpkg
2.sudo apt-get install cups -y
3.sudo usermod -a -G lpadmin your_user_name # ให้เปลี่ยน your_user_name เป็นชื่อ user ที่เราใช้ ในที่นี้คือ pi ดังนั้นเราต้องพิมพ์ sudo usermod -a -G lpadmin pi
4.sudo cupsctl --remote-admin --remote-any --share-printers
5.sudo reboot
https://www.custom.biz/en_GB/product/hardware/printers/self-service-kiosk-printers/vkp80iii
ที่ด้านล่างของเวป จะมี Driver ให้เลือก ในที่นี้ให้เลือก PRINTER VKP80III USB RS232 REAR CONN. เนื่องจากเครื่องที่ผมนำมาใช้ เป็นเครื่องที่มี Port USB อยู่ด้านหลังของเครื่อง และคลิกที่ 4u support
2.คลิก Download ที่เป็นของ Linux
3.เมื่อเรา Download มาเสร็จแล้ว ก็ให้จับโยนเข้าไปที่เครื่อง RaspberryPi แล้วแตกไฟล์ ด้วยคำสั่ง tar -vxf xxxx.tgz (xxxx คือไฟล์ที่เรา Download มา)
4.เมื่อแตกไฟล์แล้ว จะได้โฟลเดอร์ VKP80III_CUPSDrv-202-PKG มา ก็เข้าไปดู ด้วยคำสั่ง cd VKP80III_CUPSDrv-202-PKG
5.จะมี readme.txt อยู่ ให้เราเปิดอ่านดู เพื่อให้รู้ว่าต้องทำอะไรบ้าง ด้วยคำสั่ง nano readme.txt
6.ให้ออกจาก readme.txt ด้วยการกด control+x
7.พิมพ์คำสั่ง ./VKP80III_CUPSDrv-202.sh ก็จะได้ ไฟล์.pdd ออกมา เป็นอันจบขั้นตอนในส่วนนี้
1.เสียบสาย USB เข้ากับ RaspberryPi ของเรา และเปิดเครื่องปรินท์
2.เปิด web browser ขึ้นมา แล้วพิมพ์ IP ของ RaspberryPi ตามด้วย port 631 (192.168.1.27:631)
3.คลิกที่แท็ป Administration
4.คลิกที่ Add Printer
5.ให้คลิกที่ Local: CUSTOM Engineering VKP80III และคลิก Continue
6.ถ้าหากต้องการ Share printer ให้เครื่องคอมฯเครื่องอื่นๆ สามารถใช้งาน printer เครื่องนี้ได้ด้วย ก็ให้คลิกถูกที่ Share This Printer และคลิก Continue
7.ให้คลิกที่ Custom Engineering VKP80III และคลิก Add Printer
8.ให้ตั้งค่าต่างๆ ตามต้องการ
9.กด Default option เพื่อจบการติดตั้ง
10.ทดสอบพิมพ์
เป็นอันเสร็จพิธี
1.ติดตั้งโปรแกรม CUPS
2.Download และ แตกไฟล์ Driver
3.ติดตั้ง Driver ที่ CUPS
ติดตั้งโปรแกรม CUPS
โปรแกรม CUPS จะเป็นตัวจัดการเครื่องปรินท์ให้เรา มีวิธีติดตั้ง ดังนี้1.sudo apt install dpkg
2.sudo apt-get install cups -y
3.sudo usermod -a -G lpadmin your_user_name # ให้เปลี่ยน your_user_name เป็นชื่อ user ที่เราใช้ ในที่นี้คือ pi ดังนั้นเราต้องพิมพ์ sudo usermod -a -G lpadmin pi
4.sudo cupsctl --remote-admin --remote-any --share-printers
5.sudo reboot
Download และ แตกไฟล์ Driver
1.Download Driver ของเครื่องพิมพ์ที่ต้องการมาก่อนhttps://www.custom.biz/en_GB/product/hardware/printers/self-service-kiosk-printers/vkp80iii
ที่ด้านล่างของเวป จะมี Driver ให้เลือก ในที่นี้ให้เลือก PRINTER VKP80III USB RS232 REAR CONN. เนื่องจากเครื่องที่ผมนำมาใช้ เป็นเครื่องที่มี Port USB อยู่ด้านหลังของเครื่อง และคลิกที่ 4u support
3.เมื่อเรา Download มาเสร็จแล้ว ก็ให้จับโยนเข้าไปที่เครื่อง RaspberryPi แล้วแตกไฟล์ ด้วยคำสั่ง tar -vxf xxxx.tgz (xxxx คือไฟล์ที่เรา Download มา)
4.เมื่อแตกไฟล์แล้ว จะได้โฟลเดอร์ VKP80III_CUPSDrv-202-PKG มา ก็เข้าไปดู ด้วยคำสั่ง cd VKP80III_CUPSDrv-202-PKG
5.จะมี readme.txt อยู่ ให้เราเปิดอ่านดู เพื่อให้รู้ว่าต้องทำอะไรบ้าง ด้วยคำสั่ง nano readme.txt
6.ให้ออกจาก readme.txt ด้วยการกด control+x
7.พิมพ์คำสั่ง ./VKP80III_CUPSDrv-202.sh ก็จะได้ ไฟล์.pdd ออกมา เป็นอันจบขั้นตอนในส่วนนี้
ติดตั้ง Driver ที่ CUPS
จากนั้นก็ให้ลง Driver ของเครื่องพิมพ์ โดยผ่านโปรแกรม CUPS ดังนี้1.เสียบสาย USB เข้ากับ RaspberryPi ของเรา และเปิดเครื่องปรินท์
2.เปิด web browser ขึ้นมา แล้วพิมพ์ IP ของ RaspberryPi ตามด้วย port 631 (192.168.1.27:631)
3.คลิกที่แท็ป Administration
ถ้าขึ้นหน้าที่ให้ใส่ user name และ password ก็ให้เราใส่ user name และ password ที่เราใช้ log in เข้ามา

5.ให้คลิกที่ Local: CUSTOM Engineering VKP80III และคลิก Continue
6.ถ้าหากต้องการ Share printer ให้เครื่องคอมฯเครื่องอื่นๆ สามารถใช้งาน printer เครื่องนี้ได้ด้วย ก็ให้คลิกถูกที่ Share This Printer และคลิก Continue
7.ให้คลิกที่ Custom Engineering VKP80III และคลิก Add Printer
8.ให้ตั้งค่าต่างๆ ตามต้องการ
10.ทดสอบพิมพ์
เป็นอันเสร็จพิธี
วันเสาร์ที่ 4 มกราคม พ.ศ. 2563
ติดตั้ง printer epson tm-t82 บนเครื่อง PC linux
1. ถอด printer ออกจากเครื่องคอมฯก่อน
2. install CUPS
2.1 sudo apt install dpkg
2.2 sudo apt-get install cups -y
2.3 sudo usermod -a -G lpadmin your_user_name # ถ้าชื่อ user ใช้ชื่อว่า pi ก็ให้ใส่ pi ลงไปแทน your_user_name
2.4 sudo cupsctl --remote-admin --remote-any --share-printers
2.5 sudo reboot
3. download linux driver for tm-t82 โดยการเปิด web browser แล้วใส่ address นี้ลงไป
https://download.epson-biz.com/modules/pos/index.php?page=single_soft&cid=5012&scat=32&pcat=52
tmx-cups-2.0.3.0.tar.gz
4. แตกไฟล์
5. ให้ดูไฟล์ TmxDriverManual.html เพื่อดูว่าต้องทำอะไรบ้าง (ให้ดูข้อ 5.1)
6. ให้ download http://download.opensuse.org/distribution/11.4/repo/oss/suse/i586/libusb-1_0-0-1.0.8-4.1.i586.rpm
7. sudo rpm -i libusb-1_0-0-1.0.8-4.1.i586.rpm
7.1 พอดีว่าเครื่องผมมันลงไม่ผ่าน จึงทำการแก้ไข ดังนี้
7.2 sudo apt --fix-broken install
7.3 sudo apt install rpm
7.4 sudo rpm -i libusb-1_0-0-1.0.8-4.1.i586.rpm
8. ให้เลือก ubuntu 12..4 xx bit
9. sudo ./install.sh (ใน folder ที่เรา download มา)
10. เปิด printer และเสียบสาย usb เข้าเครื่องคอมฯ
11. เปิด Browser และเข้า localhost:631
12. เข้า tab Admin / Add printer
13. เลือก printer TM-T82
14. เลือก driver ที่เขียนว่า ...TM/BA...
เสร็จพิธี
2. install CUPS
2.1 sudo apt install dpkg
2.2 sudo apt-get install cups -y
2.3 sudo usermod -a -G lpadmin your_user_name # ถ้าชื่อ user ใช้ชื่อว่า pi ก็ให้ใส่ pi ลงไปแทน your_user_name
2.4 sudo cupsctl --remote-admin --remote-any --share-printers
2.5 sudo reboot
3. download linux driver for tm-t82 โดยการเปิด web browser แล้วใส่ address นี้ลงไป
https://download.epson-biz.com/modules/pos/index.php?page=single_soft&cid=5012&scat=32&pcat=52
tmx-cups-2.0.3.0.tar.gz
4. แตกไฟล์
5. ให้ดูไฟล์ TmxDriverManual.html เพื่อดูว่าต้องทำอะไรบ้าง (ให้ดูข้อ 5.1)
6. ให้ download http://download.opensuse.org/distribution/11.4/repo/oss/suse/i586/libusb-1_0-0-1.0.8-4.1.i586.rpm
7. sudo rpm -i libusb-1_0-0-1.0.8-4.1.i586.rpm
7.1 พอดีว่าเครื่องผมมันลงไม่ผ่าน จึงทำการแก้ไข ดังนี้
7.2 sudo apt --fix-broken install
7.3 sudo apt install rpm
7.4 sudo rpm -i libusb-1_0-0-1.0.8-4.1.i586.rpm
8. ให้เลือก ubuntu 12..4 xx bit
9. sudo ./install.sh (ใน folder ที่เรา download มา)
10. เปิด printer และเสียบสาย usb เข้าเครื่องคอมฯ
11. เปิด Browser และเข้า localhost:631
12. เข้า tab Admin / Add printer
13. เลือก printer TM-T82
14. เลือก driver ที่เขียนว่า ...TM/BA...
เสร็จพิธี
สมัครสมาชิก:
บทความ (Atom)













































