Raspberry Pi でスワップファイルを無効にする

スワップファイルを消して、無効にする(永続) : $ sudo swapoff --all $ sudo systemctl stop dphys-swapfile $ sudo systemctl disable dphys-swapfile check : $ sudo systemctl is-enabled dphys-swapfile > disabled $ sudo systemctl status dphys-sw…

行を間引いて表示

分毎のログを大雑把に見るため行を間引いて(スキップして)表示したい。 pythonで書いた。1 #!/usr/bin/env python3 import argparse def setup_parser(): p = argparse.ArgumentParser() p.add_argument('infile') p.add_argument('skip', type=int) retur…

import requests するとエラーが出る

エラーが出る ImportError: urllib3 v2.0 only supports OpenSSL 1.1.1+, currently the 'ssl' module is compiled with LibreSSL 2.8.3. 原因 requests(==2.30.0)最新版をインストールすると依存関係のurllib3(==2.0.2)最新版がインストールされる。 が、re…

構造体が境界調整されるのを回避する(パディング、アライメント)

構造体は境界調整される(パディング=詰め物、アライメント=調整) コンパイラがデータをメモリに効率良い様に配置する。 奇数アドレスを避け、偶数アドレスにする。 処理系によっては2byte単位ではなく4byte単位になったりする。 typedef struct { char a;…

/dev/ttyUSB0をユーザーが使えるようにする

デバイスのアクセス権はdialoutグループに所属するユーザー $ ls -l /dev/ttyUSB0 crw-rw---- 1 root dialout 188, 0 12月 6 14:11 /dev/ttyUSB0 自分(zumaa)のグループを確認、所属してない $ id -a uid=1000(zumaa) gid=1000(zumaa) groups=1000(zumaa),24…

Debian/Raspbianのバージョン情報

Linuxの情報 $ uname -a Linux raspberrypi 5.10.103-v7+ #1529 SMP Tue Mar 8 12:21:37 GMT 2022 armv7l GNU/Linux Debian/Raspbianのバージョン $ cat /etc/debian_version 10.13 $ cat /etc/issue Raspbian GNU/Linux 10 \n \l ディストリビューション情…

gcc/g++の定義済みマクロ(predefined macros)の一覧

$ gcc -dM -E - < /dev/null g++でも同じ。 [GCC][C/C++][Linux] GCCの定義済みマクロ(predefined macros)のダンプ - Qiita

warning: implicit declaration of function ‘i2c_smbus_write_byte_data’

とあるi2cを使うcコードでコンパイル警告とリンクエラーが出た。 コンパイル警告 warning: implicit declaration of function ‘i2c_smbus_write_byte_data’ warning: implicit declaration of function ‘i2c_smbus_read_byte’ リンクエラー undefined refere…

error: variable ‘std::istringstream in’ has initializer but incomplete type

何エラーか良くわからんかったが、どうやら std::istringstreamを使うには<sstream>が必要、ということだった。 ヘッダをインクルードしたら解決した。 error: variable ‘std::istringstream in’ has initializer but incomplete type std::istringstream hoge(fuga);</sstream>…

特定ユーザーでsudoを使えるようにする

(Debian 10 busterで確認) //rootに移行 $ su rootのパスワード //sudoを入れる # apt-get install sudo //特定ユーザーを追加する # visudo > ユーザー名 ALL=(ALL:ALL) ALL ctrl+x で保存 //使えるよになったか確認する # exit $ sudo -v

wiringPiの手動インストール

公式は開発終了、有志により継続中。公式の最終版は2.50 (Raspberry Pi OS 10 busterまでならパッケージがあるのでそちらを使え) git clone \ https://github.com/WiringPi/WiringPi.git \ -b final_official_2.50 cd WiringPi ./build github.com

googletestのインストール

バージョンは適宜。mock不要、インストール先指定で。 git clone https://github.com/google/googletest.git -b release-1.12.0 cd googletest mkdir build cd build cmake .. \ -DBUILD_GMOCK=OFF \ -DCMAKE_INSTALL_PREFIX:PATH=/path/to/deploy make make…