아파치 mod_wsgi 유니코드 에러

영어가 아닌 유니코드 문자 로드 시 internal server error가 발생한다. Flask 개발서버 사용 시에는 이런 문제가 발생하지 않는다.

/etc/apache2/envvars 파일에서 다음 부분을 찾아서 주석을 해제한다.

## Uncomment the following line to use the system default locale instead:
. /etc/default/locale

Flutter_blue android 설정

Flutter_blue 패키지 버전 0.8.0에서 안드로이드 에뮬레이터, 혹은 안드로이드 디바이스에서 예제코드를 실행할 때에 다음과 같은 에러가 발생하면서, 제대로 작성이 되지 않는다. (iOS 타겟에서는 제대로 작동한다)

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':flutter_blue:generateDebugProto'.
> Could not resolve all files for configuration ':flutter_blue:protobufToolsLocator_protoc'.
   > Could not find protoc-3.11.4-osx-aarch_64.exe (com.google.protobuf:protoc:3.11.4).
     Searched in the following locations:
         https://repo.maven.apache.org/maven2/com/google/protobuf/protoc/3.11.4/protoc-3.11.4-osx-aarch_64.exe

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 16s

위의 에러를 해결하기 위해서는 Gradle info를 수정해주어야 한다.

Android Studio를 실행하여 flutter앱이 위치한 폴더에 위치한 android 폴더를 프로젝트폴더로 지정하여 연다. 이후 프로젝트 로딩이 끝나면, 오른쪽편에 위치한 Gradle탭을 열고, android>flutter_blue 트리항목위에 마우스 커서를 올리고 오른쪽 버튼을 눌러 ‘Open Gradle Config’로 진입한다.

Config 내용 중 ‘

'com.google.protobuf:protoc:3.11.4' 을
'com.google.protobuf:protoc:3.17.3' 으로 수정한다.

'com.google.protobuf:protobuf-javalite:3.11.4'을
'com.google.protobuf:protobuf-javalite:3.17.3'으로 수정한다.

수정 후 config 중 해당부분의 내용은 다음과 같다.

protobuf {
    protoc {
        artifact = 'com.google.protobuf:protoc:3.17.3'
    }
    generateProtoTasks {
        all().each { task ->
            task.builtins {
                java {
                    option "lite"
                }
            }
        }
    }
}

dependencies {
    implementation 'com.google.protobuf:protobuf-javalite:3.17.3'
}

저장한 이후 Android Studio를 닫고, flutter에서 앱 시작을 해보면, 잘 실행되는 것을 볼 수가 있다.

Flutter m1칩 pod 에러

flutter로 작성한 앱을 아이폰 에뮬레이터에서 구동하려고 하니, 다음과 같은 에러가 발생.

Launching lib/main.dart on iPhone 13 in debug mode...
lib/main.dart:1
CocoaPods' output:
↳
      Preparing
    Analyzing dependencies
    Inspecting targets to integrate
      Using `ARCHS` setting to build architectures of target `Pods-Runner`: (``)
    Fetching external sources
    -> Fetching podspec for `Flutter` from `Flutter`
    -> Fetching podspec for `webview_flutter_wkwebview` from `.symlinks/plugins/webview_flutter_wkwebview/ios`
    Resolving dependencies of `Podfile`
Error output from CocoaPods:
↳
    /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require': dlopen(/Library/Ruby/Gems/2.6.0/gems/ffi-1.15.4/lib/ffi_c.bundle, 9): no suitable image found.  Did find: (LoadError)
    	/Library/Ruby/Gems/2.6.0/gems/ffi-1.15.4/lib/ffi_c.bundle: mach-o, but wrong architecture
    	/Library/Ruby/Gems/2.6.0/gems/ffi-1.15.4/lib/ffi_c.bundle: mach-o, but wrong architecture - /Library/Ruby/Gems/2.6.0/gems/ffi-1.15.4/lib/ffi_c.bundle

터미널에서 ~/ios/ 이동 후 pod install 실행 시 역시나 에러 발생

changho@177802-RedmiBook-Air ios % pod install
Analyzing dependencies
/Library/Ruby/Gems/2.6.0/gems/ffi-1.15.4/lib/ffi/library.rb:275: [BUG] Bus Error at 0x00000001022f4000
ruby 2.6.3p62 (2019-04-16 revision 67580) [universal.arm64e-darwin20]

-- Crash Report log information --------------------------------------------
   See Crash Report log file under the one of following:                    
     * ~/Library/Logs/DiagnosticReports                                     
     * /Library/Logs/DiagnosticReports                                      
   for more details.                                                        
Don't forget to include the above Crash Report log file in bug reports.     

인텔칩이 아닌 m1칩 관련 문제

다음 명령어로 gem 설치

sudo arch -x86_64 gem install ffi
arch -x86_64 pod install 

조치 후 에러 없이 정상작동함.

pip3 업그레이드

pip 가 최신버전이 아닐 때에 flask를 설치하면, import 시

flask ImportError: cannot import name ‘escape’

이와 같은 오류가 발생한다.

pip 업그레이드를 위해 get-pip 를 설치한다.

curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python3 get-pip.py

다만 python3 버전이 3.5 이하인 경우, 다음과 같이 실행한다.

curl https://bootstrap.pypa.io/pip/3.5/get-pip.py  -o get-pip.py
python3 get-pip.py

NanoPi NEO Air

NanoPi NEO Air

위키 : 링크

File:NanoPi-NEO-AIR pinout-02.jpg
nanopi neo air 핀아웃맵

eMMC에 운영체제 탑재시키기

기본 리눅스 운영체제가 설치되어 있지만, 기기를 원활히 동작시키기 위해서는 추천하는 리눅스 운영체제를 설치하여야 한다. 위키에 관련 내용이 있으며, 간략히 설명하면 다음과 같다.

  1. Win32diskimager을 이용하여 다운로드받은 linux image를 sd카드에 탑재시킨다.

– OS 이미지는 이 링크에서 다운로드 할 수 있다.

  • official-ROM 폴더의 nanopi-neo-air_eflasher_friendlycore-xenial_4.14_armhf_20191230.img.zip 을 다운로드함

2. 이미지가 기록된 sd 카드를 본체에 삽입한다.

3.usb to UART 커넥터를 이용하여 pc와 연결한다.

4.PC에서 putty를 이용하여 serial 연결을 시도한다. 이 때에 baudrate는 115200으로 설정한다.

5.다음 명령에 따라 새로운 리눅스를 설치한다.

  • For more details about eflasher refer to the wiki link: EFlasher
  • Extract the eflasher Image and win32diskimager.rar files. Insert a TF card(at least 4G) into a Windows PC and run the win32diskimager utility as administrator. On the utility’s main window select your TF card’s drive, the wanted image file and click on “write” to start flashing the TF card.
  • Insert this card into your board’s BOOT slot and power on (with a 5V/2A power source). If the green LED is on and the blue LED is blinking this indicates your board has successfully booted.
  • If your board doesn’t support HDMI or no monitor is connected you can select an OS by running the following command:
$ su root
$ eflasher

The password for “root” is “fa”.

We take “nanopi-neo-air_eflasher_friendlycore-xenial_4.14_armhf_YYYYMMDD.img” as an example. After you run the “eflasher” command you will see the following messages:

eflasher_friendlycore1
Type “1”, select writing friendlycore system to eMMC you will see the following messages:

eflasher_friendlycore2_h3
Type “yes” to start installation:

eflasher_friendlycore3
After it is done power off the system, take off the TF card, power on again your system will be booted from eMMC.

usb를 통해 전원공급받고, 4핀으로 시리얼통신을 수행중이다

로그인 시 웰컴메시지 수정

/etc/update-motd.d/10-header 파일을 수정

마우스 위치 제어

파이썬을 이용하여 마우스 위치와 버튼을 제어. gui 환경에서 사용해야한다.

필요패키지 설치

sudo pip3 install pynput

마우스 위치 제어

import pynput
mouse_con = pynput.mouse.Controller()
mouse_con.position # 현재 마우스 위치 출력
mouse_con.position = (100,100) #100, 100 위치로 이동.

부팅시 자동실행

리눅스 부팅 시 자동시작할 스크립트를

/etc/init.d/

폴더에 넣어둔다

update-rc.d [서비스명] defaults 

위의 명령으로 자동실행을 활성화한다.

자동실행을 취소할 경우

update-rc.d [서비스명] remove 

위의 방법으로 안되는 경우

sudo apt-get install chkconfig #chkconfig 설치
chkconfig [서비스명] on