전체 글
-
modbus CheckSum 구하기.Python 2022. 9. 23. 23:11
예를들어서 포멧이 아래와 같다고 하자. 01 01 03 04 ff 00 06 checkSum(crc-16 ABCD Type) https://www.scadacore.com/tools/programming-calculators/online-checksum-calculator/ Online Checksum Calculator - SCADACore SCADACore's Checksum Calculator can be used to verify the checksum algorithm used by field devices. It accepts ASCII or Hex to produce a checksum. www.scadacore.com 위 사이트에서 구해보면 이렇게 나온다. 그렇다면 파이썬에서는 어떻게 쉽게..
-
파이썬에서 시리얼 데이터 받기 (Hex Data)Python 2022. 9. 23. 23:02
여기는 Hex 형태의 시리얼 데이터를 받는 예제입니다. String 데이터는 이전 글을 보세요. 선행작업 pip install pyserial pip가 설치가 안된경우 pip 를 먼저 설치 합니다. apt install python3-pip import serial seru = serial.Serial('/dev/ttyUSB0', 115200) while True: if seru.readable(): s = seru.read() hex_string = binascii.hexlify(s).decode('utf-8') print(hex_string)
-
파이썬에서 시리얼 데이터 받기 (String Data)Python 2022. 9. 23. 22:59
여기는 String 형태의 시리얼 데이터를 받는 예제입니다. Hex 데이터는 다음 글을 보세요. 선행작업 pip install pyserial pip가 설치가 안된경우 pip 를 먼저 설치 합니다. apt install python3-pip 코드 import serial ser = serial.Serial(port='/dev/ttyUSB0', baudrate=9600, parity=serial.PARITY_NONE, stopbits=serial.STOPBITS_ONE, bytesize=serial.EIGHTBITS) while True: if ser.readable(): res = ser.readline() print(res.decode()[:len(res) - 1]) 엄청 간단하죠? 설명이 필요 없을정..
-
os.system 을 통한 터미널 명령어 사용하기.Python 2022. 9. 23. 22:54
os.system 을 사용한 echo 명령어 os.system("echo -en \x02Hello Python!\x03 > /dev/ttyS0 9600" ) ttyS0 포트로 헥사와 아스키 값을 전송한다. 그런데 위와 같이 전송하면 보드에서 못 받을때가 있다. 그럴땐 아래와 같이 터미널에서 아래와 같이 한번 입력 해주고 해줘야 동작했다. stty -F /dev/ttyS0 speed 9600 cs8 -cstopb -parenb -echo 그래서 cron 에 @reboot /home/user/sh/Setting.sh 를 등록하고 리부팅 될때 마다 자동으로 위 커멘드를 수행하게 했다.
-
안드로이드12 BT 권한강화ANDROID 2022. 2. 4. 15:20
Need android.permission.BLUETOOTH_SCAN permission for AttributionSource 아이고... targetSdkVersion 을 31로 올리면서 위 에러가 발생했다. 이 글을 보신다면 저 검색어로 오신게 아닐까?^^;;; 말 그대로 퍼미션 더 추가하란 소리 같았다. 검색해보니 역시나 많은 자료가 나왔다. https://developer.android.com/about/versions/12/features/bluetooth-permissions?hl=ko Android 12의 새 블루투스 권한 | Android Developers 내년 초 출시될 대형 화면용 기능 출시인 12L을 준비하세요. 지금 사용해 보기 Android 12의 새 블루투스 권한 Androi..
-
android12 targetSdkVersion 31 패키지를 파싱하는중 문제가 발생했습니다ANDROID 2022. 2. 4. 14:37
평소처럼 코딩하고 고객에게 줬더니 저번주까지는 잘 설치된게 갑자기 안된다고 했다. 알고보니 설 연휴에 안드로이드12 버전으로 업데이트를 했고 확인을 해보니 안드로이드12 + targetSdkVersion 31 (build.gradle) 로 컴파일 하니 아래 2개 처럼 .APK 로만 나오고 패키지를 파싱하는 중 문제가 발생했습니다. 라고 안내가 나왔다. 안드로이드12+ targetSdkVersion 30 (build.gradle) 에서는 정상적으로 설치되는걸 보고 수정을 시작했다. AndroidManifest.xml As of Android 12, android:exported must be set; use true to make the activity available to other apps, and ..
-
두 gps 지점으로 방위각 구하기Python 2022. 1. 24. 15:18
php 로 짜다가 파이썬으로 바꿔야 해서 구글링 시작 사실 구글링 하다보면 나오긴 하는데... 각도가 2~3도씩이나 차이가 나서 쓸수가 없었다. C언어로는 많아서 그냥 파이썬에서 C를 불러다 쓸까~ㅎㅎ 하다가 아우~ 이것도 귀찮아서 파이썬으로 짰다 그냥 https://www.omnicalculator.com/other/azimuth Azimuth Calculator If you want to give a location of a point relative to your current position, you need to provide two values: the azimuth and the distance. If Earth was flat, the latter would simply by the str..
-
두 gps 지점으로 방위각 구하기PHP 2022. 1. 24. 14:50
방위각 계산 사이트 와 실제 코드를 통해 나온 결과값을 비교해 보고 시작하자. https://www.omnicalculator.com/other/azimuth Azimuth Calculator If you want to give a location of a point relative to your current position, you need to provide two values: the azimuth and the distance. If Earth was flat, the latter would simply by the straight-line distance between two points. As Earth is a sphere (or www.omnicalculator.com 347.4도 라고 ..