>> 윈11 ollama 에서 다른 컴의 ollama 자원 사용.
set OLLAMA_HOST="http://192.168.0.x:11434"
ollama list
지덩된 호스트의 모델목록 ...
ollama launch claude
>> 윈11 ollama 에서 다른 컴의 ollama 자원 사용.
set OLLAMA_HOST="http://192.168.0.x:11434"
ollama list
지덩된 호스트의 모델목록 ...
ollama launch claude
>> Raspbian 2020-04-19 update, kernel 3.10.108 버전 img 설치.
2020-04-19-raspbian-jessie-bpi-m2u-sd-emmc.img.zip
마이크로 SD 카드에 이미지 적재.
![]()
보드에 전원 켜고
putty 로그인.
시리얼 로그인 pi / bananapi
usb메모리에 동일한 img.zip 파일을 그대로 넣어주고
# bpi-copy 2020-04-19-raspbian-jessie-bpi-m2u-sd-emmc.img.zip /dev/mmcblk0
완료 후 error
# bpi-bootsel 사용해야 정상적으로 emmc 에 설치 & 부팅 가능.
우분투 서버.
# bpi-bootsel /mnt/jjj/2020-04-19-ubuntu-16.04-server-bpi-m2u-sd-emmc.img.zip /dev/mmcblk1
bpi-bootsel, emmc 기존 os 설치되어 있으면 wipe 후에 설치.
>> 전원공급.
USB 전원 공급 5V 2A 어댑터 사용. --> 보드 다운 증상.
5V2A DC 어댑터로 전원 공급 --> 정상 작동.
>> 우분투 설치.
마이크로 sd 카드에 배포 이미지 설치.
기존 emmc에 os 설치된 경우 마이크로SD 부팅이 안될수도 있습니다.
mSD 부팅하기 위해
mSD 카드 제거 후, 기존 emmc os 부팅하기 위해 리셋버튼.
uboot 진입 --> mSD 카드 장착 -> #run bootcmd ( mSD 부팅)
>> mSD 부팅, emmc 8GB 재 포맷 후 일반 드라이브로 사용가능.
또는 반대로 가능.
>> 우분투 gui 제거.
1. 우분투 데스크탑 환경 제거
sudo apt-get remove ubuntu-desktop
2. GNOME 데스크톱 매니저 제거
sudo apt-get remove gdm3
3. 그래픽 드라이버 제거
sudo apt-get remove xserver-xorg-video-*
4. 그래픽 서버 제거
sudo apt-get remove xserver-xorg-core
5. autoremove
sudo apt-get autoremove
6. 재부팅
sudo reboot
>> removed v3d driver.
부팅시 드라이버 'v3d' 에러 메시지.
# journalctl |more 확인 후 에러 정정.
apt-get update --fix-missing
https://wiki.banana-pi.org/Getting_Started_with_M2_Ultra_%26_Berry
apt-get install apache2 php5 libapache2-mod-php5
>> nginx 바나나파이.
우분투 emmc 설치 후.
apt-get update
lock pkg 메시지.
Could not get lock /var/lib/dpkg/lock-frontend - open (11: Resource temporarily unavailable)
1) sudo killall apt apt-get
만일 진행중인 프로세스가 없다
아래와 같이 하나하나씩 디렉토리를 삭제./
#rm /var/lib/apt/lists/lock
#rm /var/cache/apt/archives/lock
#rm /var/lib/dpkg/lock*
#dpkg --configure -a
#apt update
#apt-get update
#apt-get upgrade
>> 방화벽 체크 및 설정.
apt-get install nginx
/etc/init.d/nginx start
apt-get install mysql-server
apt-get install php5-fpm
apt-get install php-mysql
apt-get install php-apc
nginx 부팅 시작시 에러메시지.
nginx 버전 또는 다른 문제일지는 모르겠지만.
>> /var/log/nginx/ 로그 파일 생성하지 못해서 서비스 시작 못하는 증상.
직접 /etc/nginx/conf.d/ 디렉토리를 생성한 후, 필요한 구성 파일을 추가하세요1.
Nginx의 메인 구성 파일
/etc/nginx/nginx.conf에서 include /etc/nginx/conf.d/*.conf;라는 줄이 있는지 확인.
nginx 소스코드를 확인해쟈 정확하겠자만. /var/log 는 우분투에서는 임시 메모리 디렉터리로
기억됨.
nginx 서비스에서 /var/log/nginx 라는 디렉터리를 생성 권한 없거나
nginx 코드 자체에서 디렉터리 체크 없이 무조건 열기 하는것으로 추측됨.
/etc/nginx/nginx
>> apt install phpmyadmin 설치 시
apache2 연관 설치되는 문제.
>> ArmBian OS 교체 설치.
apache2 설치 완료. phpMyAdmin 설치완료.
>> apache2
웹서버 포트 홈 디렉터리 지정.
Listen 80
Listen 8080
Then create two vhost configurations (/etc/apache/sites-enabled/000-default). The first can be *:80 and the second *:8080. Set the respective DocumentRoots.
<VirtualHost *:80>
DocumentRoot ~/public_html
Blah Blah....
</VirtualHost>
and...
<VirtualHost *:8080>
DocumentRoot ~/public_html/something
Blah Blah....
</VirtualHost>
>> 호스트 명칭 변경. ubuntu 16.4
# hostnamectl set-hostname "nas m2u"
# hostnamectl status
Static hostname: nasm2u
Pretty hostname: nas m2u
Icon name: computer
Machine ID: bad4775cb70c41dc85c9b140e9434836
Boot ID: 3c7d01cbf03a40c0b66d466109a7b5e5
Operating System: Ubuntu 16.04.7 LTS
Kernel: Linux 3.10.108-BPI-M2U-Kernel
Architecture: arm
## VS Code 확장 프로그램
Multiple cursor case preserve
다중 커서, 단어 변경 대소문자 반영 플러그인 프로그램.
코드중에 변경하고 싶은 단어 Ctrl + D ( 윈도우 버전 ) 여러개 선택 후
변경 해주면 됩니다.
chatgpt 에게 아두이노 코드의 pulsein 함수를 사용하지 않고 사용하는 방법에 대해 질문 해본 결과입니다.
굉장히 유능한 코드를 보여주고 있습니다.
Yes, it is possible to measure distance using an HC-SR04 ultrasonic sensor without using the pulseIn() function in Arduino.
One way to do this is to use the pulseIn() function to calculate the duration of the pulse, and then convert this duration to a distance. Here's an example code:
chatgpt 는 pulsein함수를 사용하는 방법을 우선 설명해주고 있습니다.
const int trigPin = 9;
const int echoPin = 10;
void setup() {
Serial.begin(9600);
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
}
void loop() {
long duration, distance;
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
distance = duration * 0.034 / 2;
Serial.print("Distance: ");
Serial.print(distance);
Serial.println(" cm");
delay(500);
}
However, if you don't want to use the pulseIn() function, you can use the pulse timing directly. Here's an example code that demonstrates this approach:
다음으로는 pulsein 함수를 대체하는 방법을 말해주고 있습니다.
const int trigPin = 9;
const int echoPin = 10;
void setup() {
Serial.begin(9600);
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
}
void loop() {
long duration, distance;
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
duration = pulseTiming(echoPin, HIGH, 10000);
distance = duration * 0.034 / 2;
Serial.print("Distance: ");
Serial.print(distance);
Serial.println(" cm");
delay(500);
}
long pulseTiming(int pin, int level, long timeout) {
long start = micros();
while (digitalRead(pin) != level) {
if (micros() - start > timeout) {
return 0;
}
}
start = micros();
while (digitalRead(pin) == level) {
if (micros() - start > timeout) {
return 0;
}
}
return micros() - start;
}
다음은 인터럽트를 사용해서 사용가능하냐고 질문해보았습니다.
Yes, it is possible to use interrupt functions to measure distance with the HC-SR04 ultrasonic sensor in Arduino.
One way to do this is to use an interrupt function to detect the rising edge of the echo signal, and then use the micros() function to measure the duration of the pulse. Here's an example code:
const int trigPin = 9;
const int echoPin = 10;
volatile long startMicros, endMicros, pulseDuration;
void setup() {
Serial.begin(9600);
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
attachInterrupt(digitalPinToInterrupt(echoPin), echoISR, RISING);
}
void loop() {
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
delay(50);
pulseDuration = endMicros - startMicros;
long distance = pulseDuration * 0.034 / 2;
Serial.print("Distance: ");
Serial.print(distance);
Serial.println(" cm");
delay(500);
}
void echoISR() {
if (digitalRead(echoPin) == HIGH) {
startMicros = micros();
} else {
endMicros = micros();
}
}
질문에 대한 답을 해주고 마무리 설명까지 해줍니다.
In this code, the echoISR() function is triggered by the rising edge of the echo signal, and uses the micros() function to measure the duration of the pulse. The pulse duration is stored in the global variable pulseDuration, which is then used to calculate the distance. The delay(50) in the loop() function allows time for the pulse to be received and processed before the next measurement is taken.
Note that in this example code, the pulse duration is measured in microseconds rather than in milliseconds as in the previous examples. This provides greater accuracy, as micros() has a resolution of 4 microseconds.
아두이노 라이브러리 함수를 사용하지 않고, 원래 사용하던 AVR 코드를 사용해서 SR04 거리센서 측정에 대해
다시 물어보았습니다.
Sure, here is an example AVR code for measuring distance with the HC-SR04 ultrasonic sensor without using Arduino libraries:
#include <avr/io.h>
#include <util/delay.h>
#include <avr/interrupt.h>
#define TRIG_PIN PB1
#define ECHO_PIN PB2
volatile uint16_t pulse_start_time, pulse_end_time;
volatile uint8_t echo_detected = 0;
void setup()
{
// Set up Timer/Counter1 for input capture
TCCR1B |= (1 << ICES1); // capture rising edge
TCCR1B |= (1 << CS10); // no prescaler
TIMSK1 |= (1 << ICIE1); // enable input capture interrupt
// Set up I/O pins
DDRB |= (1 << TRIG_PIN); // set TRIG pin as output
DDRB &= ~(1 << ECHO_PIN); // set ECHO pin as input
// Set up global interrupts
sei();
}
void loop()
{
// Trigger a pulse
PORTB |= (1 << TRIG_PIN); // set TRIG pin high
_delay_us(10); // pulse width > 10 us
PORTB &= ~(1 << TRIG_PIN); // set TRIG pin low
// Wait for echo pulse to be detected
while (!echo_detected) {
// do nothing
}
echo_detected = 0; // clear flag
// Calculate distance from pulse duration
uint32_t pulse_duration = (pulse_end_time - pulse_start_time);
uint16_t distance = pulse_duration * 0.034 / 2;
// Output distance to serial
// ...
}
ISR(TIMER1_CAPT_vect)
{
uint16_t pulse_time = ICR1; // capture timer value
if (TCCR1B & (1 << ICES1)) { // rising edge detected
pulse_start_time = pulse_time;
TCCR1B &= ~(1 << ICES1); // capture falling edge
} else { // falling edge detected
pulse_end_time = pulse_time;
echo_detected = 1; // set flag
TCCR1B |= (1 << ICES1); // capture rising edge
}
}
Wow..
>> git pull 시 stash 또는 merge 를 우선 하라고 나올 때,
중요하지 않은 파일 또는 덮어쓰기 해도 무방한 파일들이라고 판단되는 경우.
이클립스 터미널 창에서
1. git pull 받을 목록을 repository 에서 업데이트
git fetch --all2. git reset 으로 head를 최신으로 가리킨다
git reset --hard origin/main3. git pull 로 확인
git pull최신버전 헤드 & pull 완료.
>> 웹소켓 json 수신
const socket = new WebSocket('ws://localhost:8080');
socket.onmessage = function(event) { // // }
>>>>>>>>>>>>>>>>
<!DOCTYPE html>
<html>
<head>
<script src="https://d3js.org/d3.v6.min.js"></script>
</head>
<body>
<svg id="bar-chart"></svg>
<script>
const socket = new WebSocket('ws://localhost:8080');
socket.onmessage = function(event) {
const data = JSON.parse(event.data);
const svg = d3.select('#bar-chart');
const margin = { top: 20, right: 20, bottom: 30, left: 40 };
const width = +svg.attr('width') - margin.left - margin.right;
const height = +svg.attr('height') - margin.top - margin.bottom;
const x = d3.scaleBand().rangeRound([0, width]).padding(0.1);
const y = d3.scaleLinear().rangeRound([height, 0]);
const g = svg.append('g')
.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')');
x.domain(data.map(function(d) { return d.letter; }));
y.domain([0, d3.max(data, function(d) { return d.frequency; })]);
g.append('g')
.attr('class', 'axis axis--x')
.attr('transform', 'translate(0,' + height + ')')
.call(d3.axisBottom(x));
g.append('g')
.attr('class', 'axis axis--y')
.call(d3.axisLeft(y).ticks(10, '%'))
.append('text')
.attr('transform', 'rotate(-90)')
.attr('y', 6)
.attr('dy', '0.71em')
.attr('text-anchor', 'end')
.text('Frequency');
g.selectAll('.bar')
.data(data)
.enter().append('rect')
.attr('class', 'bar')
.attr('x', function(d) { return x(d.letter); })
.attr('y', function(d) { return y(d.frequency); })
.attr('width', x.bandwidth())
.attr('height', function(d) { return height - y(d.frequency); });
};
</script>
</body>
</html>