Linux2022. 8. 31. 18:21

'Linux' 카테고리의 다른 글

systemctl status 전체 로그 보기  (0) 2022.11.30
리눅스 경로 / 와 // 와 ///  (0) 2022.11.01
uvcdynctrl  (0) 2022.07.06
dmesg -w  (0) 2022.06.30
dmesg log_buf_len  (0) 2022.06.29
Posted by 구차니
Programming/golang2022. 8. 31. 18:00

golang을 이용해서 rest 서버를 만드는데 가장 만만한(?) 녀석은

net/http 모듈의 http.HandleFunc() 인데

 

pattern 이라고 써넣고는 막상 설명이 없다.

func HandleFunc(pattern string, handler func(ResponseWriter, *Request))

[링크 : https://pkg.go.dev/net/http#HandleFunc]

 

음.. 소스를 봐도 모르겠다.

// Handle registers the handler for the given pattern.
// If a handler already exists for pattern, Handle panics.
func (mux *ServeMux) Handle(pattern string, handler Handler) {
mux.mu.Lock()
defer mux.mu.Unlock()

if pattern == "" {
panic("http: invalid pattern")
}
if handler == nil {
panic("http: nil handler")
}
if _, exist := mux.m[pattern]; exist {
panic("http: multiple registrations for " + pattern)
}

if mux.m == nil {
mux.m = make(map[string]muxEntry)
}
e := muxEntry{h: handler, pattern: pattern}
mux.m[pattern] = e
if pattern[len(pattern)-1] == '/' {
mux.es = appendSorted(mux.es, e)
}

if pattern[0] != '/' {
mux.hosts = true
}
}

[링크 : https://cs.opensource.google/go/go/+/refs/tags/go1.19:src/net/http/server.go;drc=ddc93a536faf4576d182cd3197b116d61d05c484;l=2480]

 

걍.. gin 모듈을 쓰는게 속 편하려나?

[링크 : https://stackoverflow.com/questions/6564558/wildcards-in-the-pattern-for-http-handlefunc]

 

'Programming > golang' 카테고리의 다른 글

golang http redirect  (0) 2022.09.02
golang html form post 처리하기  (0) 2022.09.02
golang mariadb 연동  (0) 2022.08.30
golang channel  (0) 2022.08.18
golang unused import  (0) 2022.07.20
Posted by 구차니

 

 

select current_timestamp(3)

[링크 : https://stackoverflow.com/questions/9624284/current-timestamp-in-milliseconds]

 

NOW([precision])
CURRENT_TIMESTAMP
CURRENT_TIMESTAMP([precision])
LOCALTIME, LOCALTIME([precision])
LOCALTIMESTAMP
LOCALTIMESTAMP([precision])

[링크 : https://mariadb.com/kb/en/now/]

'프로그램 사용 > mysql & mariaDB' 카테고리의 다른 글

mariadb 초기설정  (0) 2022.08.30
mariadb c# connector  (0) 2021.10.22
HeidiSQL  (2) 2021.08.18
sql zerofill  (0) 2019.11.25
mysql-dump compatible 함정 -_-  (0) 2019.09.04
Posted by 구차니
프로그램 사용/rtl-sdr2022. 8. 30. 18:16

 

SDRangel can decode multiple broadcast FM channels simultaneously

[링크 : https://www.reddit.com/r/RTLSDR/comments/ql1jpe/problem_rtl_sdr_recording_multiple_fm_channel/]

 

SDRangel is an Open Source Qt5 / OpenGL 3.0+ SDR and signal analyzer frontend to various hardware.

[링크 : https://github.com/f4exb/sdrangel]

[링크 : https://github.com/f4exb/sdrangelcli]

 

[링크 : https://github.com/szpajder/RTLSDR-Airband]

[링크 : https://github.com/pvachon/tsl-sdr]

  [링크 : https://www.rtl-sdr.com/a-multichannel-fm-demodulator/]

'프로그램 사용 > rtl-sdr' 카테고리의 다른 글

ubuntu 18.04에 사운드 카드가 갑자기 사라졌다?  (0) 2022.07.20
RTL-SDR 11시 땡!  (0) 2022.01.07
gqrx 오디오 스트리밍  (0) 2022.01.07
rpi gqrx  (0) 2022.01.07
rtl sdr am  (0) 2022.01.07
Posted by 구차니

빨간 해골을 못 찾아서

동영상 따라가면서 추적중 ㅠㅠ

어우.. 공중에 떠있는 돌을 따라서 가는게 왜이렇게 눈에 안들어 왔을 고

[링크 : https://youtu.be/EqLxO7d3u2s?t=1282]

'게임 > 오리진&스팀&유플레이' 카테고리의 다른 글

abzu 플레이  (0) 2023.05.29
epic 무료게임 - 데스 스트랜딩  (0) 2022.12.26
macos 에픽게임즈  (0) 2022.05.27
macos 스팀 게임  (0) 2022.05.27
epic games - troy  (0) 2020.08.13
Posted by 구차니
Programming/golang2022. 8. 30. 12:31

테스트 해보니

localhost:3306 접속시에는 username:password@/dbname 식으로 접속해도 된다.

 

db, _ := sql.Open("mysql", "dellis:@/shud")

[링크 : https://mariadb.com/ko/resources/blog/using-go-with-mariadb/]

[링크 : https://pkg.go.dev/database/sql]

 

db, err := sql.Open("mysql", "root:pwd@tcp(127.0.0.1:3306)/testdb")

[링크 : http://golang.site/go/article/107-MySql-사용---쿼리]

'Programming > golang' 카테고리의 다른 글

golang html form post 처리하기  (0) 2022.09.02
golang http.HandleFunc(pattern)  (0) 2022.08.31
golang channel  (0) 2022.08.18
golang unused import  (0) 2022.07.20
golang websocket package  (0) 2022.07.15
Posted by 구차니
embeded/raspberry pi2022. 8. 30. 10:48

apahce2 mariadb php7.4 를 설치해도

phpinfo()가 작동안되서 한참을 헤맸다 -_

 

$ sudo apt-get install libapache2-mod-php7.4

[링크 : https://oopaque.tistory.com/91]

'embeded > raspberry pi' 카테고리의 다른 글

rpi 3b+ PMIC 손상  (0) 2022.11.30
rpi4 eeprom recovery  (0) 2022.10.14
adxl345 spi  (0) 2022.08.17
tea5767 모듈 땜질  (0) 2022.08.17
rpi3b에서 wayvnc 빌드 + 실행하기  (0) 2022.08.10
Posted by 구차니

어쩐지(?) mariadb 설치시 암호를 안물어 본다고 했더니

저런 이상한(?) 스크립트를 추가해놓은 듯.

 

$ sudo mysql_secure_installation

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we'll need the current
password for the root user. If you've just installed MariaDB, and
haven't set the root password yet, you should just press enter here.

Enter current password for root (enter for none):
OK, successfully used password, moving on...

Setting the root password or using the unix_socket ensures that nobody
can log into the MariaDB root user without the proper authorisation.

You already have your root account protected, so you can safely answer 'n'.

Switch to unix_socket authentication [Y/n]
Enabled successfully!
Reloading privilege tables..
 ... Success!


You already have your root account protected, so you can safely answer 'n'.

Change the root password? [Y/n]
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
 ... Success!


By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n]
 ... Success!

Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] y
 ... Success!

By default, MariaDB comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] y
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] y
 ... Success!

Cleaning up...

All done!  If you've completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!

[링크 : https://bugwhale.tistory.com/39]

'프로그램 사용 > mysql & mariaDB' 카테고리의 다른 글

mariadb msec 단위 시간 얻기  (0) 2022.08.31
mariadb c# connector  (0) 2021.10.22
HeidiSQL  (2) 2021.08.18
sql zerofill  (0) 2019.11.25
mysql-dump compatible 함정 -_-  (0) 2019.09.04
Posted by 구차니
모종의 음모/HDLC2022. 8. 29. 14:42

 

Flag field가 아닌 Data에 0x7E가 있는지 확인

0x7E -< 0x7D, 0x5E를 삽입

[링크 : https://blog.daum.net/trts1004/12109121]

 

232와 같은 비동기 전송일 경우 bit stuff를 적용하지 않는다고..?

Synchronous framing
Because a flag sequence consists of six consecutive 1-bits, other data is coded to ensure that it never contains more than five 1-bits in a row. This is done by bit stuffing: any time that five consecutive 1-bits appear in the transmitted data, the data is paused and a 0-bit is transmitted.


Asynchronous framing
When using asynchronous serial communication such as standard RS-232 serial ports, synchronous-style bit stuffing is inappropriate for several reasons:

Bit stuffing is not needed to ensure an adequate number of transitions, as start and stop bits provide that,
Because the data is NRZ encoded for transmission, rather than NRZI encoded, the encoded waveform is different,
RS-232 sends bits in groups of 8, making adding single bits very awkward, and
For the same reason, it is only necessary to specially code flag bytes; it is not necessary to worry about the bit pattern straddling multiple bytes.
Instead asynchronous framing uses "control-octet transparency", also called "byte stuffing" or "octet stuffing". The frame boundary octet is 01111110, (0x7E in hexadecimal notation). A "control escape octet", has the value 0x7D (bit sequence '10111110', as RS-232 transmits least-significant bit first). If either of these two octets appears in the transmitted data, an escape octet is sent, followed by the original data octet with bit 5 inverted. For example, the byte 0x7E would be transmitted as 0x7D 0x5E ("10111110 01111010"). Other reserved octet values (such as XON or XOFF) can be escaped in the same way if necessary.

The "abort sequence" 0x7D 0x7E ends a packet with an incomplete byte-stuff sequence, forcing the receiver to detect an error. This can be used to abort packet transmission with no chance the partial packet will be interpreted as valid by the receiver.

[링크 : https://en.wikipedia.org/wiki/High-Level_Data_Link_Control]

Posted by 구차니
모종의 음모/HDLC2022. 8. 29. 14:28

잘 작동하는지 모름, 걍 밑바닥에서 부터 작성함

 

$ cat hdlc_nrzi_enc.c
#include <stdio.h>

void main()
{
        unsigned char data[10] =                {0x7E, 0x11, 0x22, 0x33, 0x1E, 0x0A, 0x7E, 0x00, 0x00, 0x00};
        unsigned char lsbmsb[10] =              {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
        unsigned char bitstuff[10] =    {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
        unsigned char nrzi[10] =                {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};

        int i = 0;
        int b = 0;

        // msb to lsb, data order change
        printf("bitwise LSB convert ----------------------------------------\n");
        for(i = 0; i < 10; i++)
        {
                unsigned char tempval = 0;
                unsigned char orival = 0;
                orival = data[i];
                for(b = 0; b < 8; b++)
                {
                        tempval |= ((orival & 0x01) << (7 - b));
                        orival = orival >> 1;
                }
                lsbmsb[i] = tempval;
                printf("%02X -> %02X\n",data[i],lsbmsb[i]);
        }

        // zrzi
        printf("NRZ-I ----------------------------------------\n");
        unsigned char last = 0;
        unsigned char out = 0;
        for(i = 0; i < 80; i++)
        {
                last = (lsbmsb[i / 8] >> (7 - (i % 8))) & 0x01;
//              printf("i:%d l:%d ", i, last);
                if(last == 0)
                        out=(out==0?1:0);
//              printf("o:%d\n", out);
                nrzi[i / 8] |= out << (7 - (i % 8));

                if(i % 8 == 7)
                        printf("%02X -> %02X\n", lsbmsb[i/8],nrzi[i/8]);
        }
}
$ ./enc
bitwise LSB convert ----------------------------------------
7E -> 7E
11 -> 88
22 -> 44
33 -> CC
1E -> 78
0A -> 50
7E -> 7E
00 -> 00
00 -> 00
00 -> 00
NRZ-I ----------------------------------------
7E -> FE
88 -> 5A
44 -> D2
CC -> 22
78 -> FA
50 -> CA
7E -> FE
00 -> AA
00 -> AA
00 -> AA

 

 

$ cat hdlc_nrzi_dec.c
#include <stdio.h>

void main()
{
        unsigned char data[10] =                {0xFE, 0x5A, 0xD2, 0x22, 0xFA, 0xCA, 0xFE, 0x00, 0x00, 0x00};
        unsigned char lsbmsb[10] =              {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
        unsigned char bitstuff[10] =    {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
        unsigned char nrzi[10] =                {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};

        int i = 0;
        int b = 0;

        // zrzi
        printf("NRZ-I ----------------------------------------\n");
        unsigned char last = 0;
        unsigned char curr = 0;
        unsigned char out = 0;
        for(i = 0; i < 80; i++)
        {
                curr = (data[i / 8] >> (7 - (i % 8))) & 0x01;
//              printf("i:%d l:%d c:%d ", i, last, curr);
                if(last != curr)
                        out = 0;
                else out = 1 ;
                last = curr;
//              printf("o:%d\n", out);
                nrzi[i / 8] |= out << (7 - (i % 8));

                if(i % 8 == 7)
                        printf("%02X -> %02X\n", data[i/8],nrzi[i/8]);
        }

        // msb to lsb, data order change
        printf("bitwise LSB convert ----------------------------------------\n");
        for(i = 0; i < 10; i++)
        {
                unsigned char tempval = 0;
                unsigned char orival = 0;
                orival = nrzi[i];
                for(b = 0; b < 8; b++)
                {
                        tempval |= ((orival & 0x01) << (7 - b));
                        orival = orival >> 1;
                }
                lsbmsb[i] = tempval;
                printf("%02X -> %02X\n",nrzi[i],lsbmsb[i]);
        }

}
$ ./dec
NRZ-I ----------------------------------------
FE -> 7E
5A -> 88
D2 -> 44
22 -> CC
FA -> 78
CA -> 50
FE -> 7E
00 -> FF
00 -> FF
00 -> FF
bitwise LSB convert ----------------------------------------
7E -> 7E
88 -> 11
44 -> 22
CC -> 33
78 -> 1E
50 -> 0A
7E -> 7E
FF -> FF
FF -> FF
FF -> FF

'모종의 음모 > HDLC' 카테고리의 다른 글

HDLC bit stuff  (0) 2022.08.29
hdlc 프로토콜 - bit stuffing, endian?  (0) 2022.08.26
HDLC FCS ccitt-1 16bit crc  (0) 2021.12.06
HDLC 프로토콜(High level Data Link Control)  (0) 2021.07.27
Posted by 구차니