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 설치 실패  (0) 2025.03.04
mariadb msec 단위 시간 얻기  (0) 2022.08.31
mariadb c# connector  (0) 2021.10.22
HeidiSQL  (2) 2021.08.18
sql zerofill  (0) 2019.11.25
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 구차니
Programming/C Win32 MFC2022. 8. 29. 11:43

무슨 마법인진 모르겠다.

아무튼.. for  문으로 32bit를 뒤집으려면

최소한 비트 * 5 이상의 연산이 필요할텐데(쉬프트, and , or, for문 비교, for문 증가)

 

[링크 : https://stackoverflow.com/questions/746171/efficient-algorithm-for-bit-reversal-from-msb-lsb-to-lsb-msb-in-c]

'Programming > C Win32 MFC' 카테고리의 다른 글

free(): invalid next size (normal)  (0) 2023.12.18
c에서 cpp 함수 불러오기  (0) 2023.01.04
kore - c restful api server  (0) 2022.07.07
fopen exclusivly  (0) 2021.07.09
vs2019 sdi , mdi 프로젝트 생성하기  (0) 2021.07.08
Posted by 구차니

위중증은 늘어나는 느낌인데 확진자는 줄어든다..

그렇다면 치명율이 높아져 전염율이 떨어질 정도라는 걸까

아니면 확진자 수를 줄이기 위해 검사를 하지 않는 걸까?

 

 

위중증 환자 600명 육박, 확진자 5만명 밑으로

[링크 : https://v.daum.net/v/20220829103600936]

Posted by 구차니
embeded/Cortex-M3 STM2022. 8. 29. 10:37

STM32F는 이렇게 단순한데

 

검색한 내용중에 H와 G 시리즈가 걸려 나와서

STM32G로 검색해서 가장 위에 있던 STM32G030C6Tx로

프로젝트 구성해보니 내용이 많이 나온다. 눈에 띄는건.. MSB First 라는 항목

 

main.c는 아래와 같이 생성되었고

  /* USER CODE END USART1_Init 1 */
  huart1.Instance = USART1;
  huart1.Init.BaudRate = 115200;
  huart1.Init.WordLength = UART_WORDLENGTH_8B;
  huart1.Init.StopBits = UART_STOPBITS_1;
  huart1.Init.Parity = UART_PARITY_NONE;
  huart1.Init.Mode = UART_MODE_TX_RX;
  huart1.Init.HwFlowCtl = UART_HWCONTROL_NONE;
  huart1.Init.OverSampling = UART_OVERSAMPLING_16;
  huart1.Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE;
  huart1.Init.ClockPrescaler = UART_PRESCALER_DIV1;
  huart1.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_DMADISABLEONERROR_INIT|UART_ADVFEATURE_MSBFIRST_INIT;
  huart1.AdvancedInit.DMADisableonRxError = UART_ADVFEATURE_DMA_DISABLEONRXERROR;
  huart1.AdvancedInit.MSBFirst = UART_ADVFEATURE_MSBFIRST_ENABLE;

 

Stm32g0xx_hal_uart.h를 따라가면 아래와 같이 먼가 있긴 하다.(귀찮아..)

#define UART_ADVFEATURE_NO_INIT                 0x00000000U          /*!< No advanced feature initialization       */
#define UART_ADVFEATURE_TXINVERT_INIT           0x00000001U          /*!< TX pin active level inversion            */
#define UART_ADVFEATURE_RXINVERT_INIT           0x00000002U          /*!< RX pin active level inversion            */
#define UART_ADVFEATURE_DATAINVERT_INIT         0x00000004U          /*!< Binary data inversion                    */
#define UART_ADVFEATURE_SWAP_INIT               0x00000008U          /*!< TX/RX pins swap                          */
#define UART_ADVFEATURE_RXOVERRUNDISABLE_INIT   0x00000010U          /*!< RX overrun disable                       */
#define UART_ADVFEATURE_DMADISABLEONERROR_INIT  0x00000020U          /*!< DMA disable on Reception Error           */
#define UART_ADVFEATURE_AUTOBAUDRATE_INIT       0x00000040U          /*!< Auto Baud rate detection initialization  */
#define UART_ADVFEATURE_MSBFIRST_INIT           0x00000080U          /*!< Most significant bit sent/received first */


#define USART_CR2_MSBFIRST_Pos       (19U)
#define USART_CR2_MSBFIRST_Msk       (0x1UL << USART_CR2_MSBFIRST_Pos)         /*!< 0x00080000 */
#define USART_CR2_MSBFIRST           USART_CR2_MSBFIRST_Msk                    /*!< Most Significant Bit First */


#define UART_ADVFEATURE_MSBFIRST_DISABLE    0x00000000U             /*!< Most significant bit sent/received
                                                                         first disable                      */
#define UART_ADVFEATURE_MSBFIRST_ENABLE     USART_CR2_MSBFIRST      /*!< Most significant bit sent/received
                                                                         first enable                       */

 

The USART can also communicate synchronously. It can operate as a SPI in Master or Slave mode with programmable clock polarity (CPOL) and phase (CPHA) and programmable data order with MSB or LSB first. The clock is output (in case of Master mode) or input (in case of Slave mode) on the CK pin. No clock pulses are provided during the start and stop bits. When the USART is configured in SPI slave mode, it supports the Transmit underrun error and the NSS hardware or software management.

[링크 : https://www.st.com/.../en.STM32G0-Peripheral-USART-interface-USART.pdf]

[링크 : https://www.st.com/.../en.STM32H7-Peripheral-USART_interface_USART.pdf]

'embeded > Cortex-M3 STM' 카테고리의 다른 글

stm32 tim output compare(OC) mode  (0) 2024.07.12
stm32 reset 없이 JTAG 붙이기  (0) 2023.07.19
stm32 wdg 최대 설정시간  (0) 2021.08.09
stm32 RST pull-up reset fail  (0) 2021.08.02
STM32 RDP(ReaD Protection)  (0) 2021.07.02
Posted by 구차니
Apple2022. 8. 27. 22:38

어찌된 게 찾아봐도..

크램쉘 모드라고 하는 USB 키보드,마우스,트랙패드 달고 화면만 쓰지 않는 모드만 나오고

윈도우나 리눅스 처럼 키보드 트랙패드는 노트북 본체의 것을 사용하고 화면만 외부 모니터를 메인으로 사용하는 건 존재하지 않는 듯.

이런 이상한 사용 시나리오는 애플에서 허용할 수 없는 건가?

 

[링크 : https://apple.stackexchange.com/questions/269853/]

'Apple' 카테고리의 다른 글

애플 무선 키보드 주웠다 버림  (0) 2024.01.01
맥북 초기화 하기  (0) 2022.12.27
macos catalina iso 파일  (0) 2022.06.23
macos iso  (0) 2022.06.20
맥 화면 90도 돌리기  (0) 2022.06.18
Posted by 구차니
embeded/ARM2022. 8. 26. 18:25

왜 찾게 되었냐면.. 알고 싶지 않았습니다.. -_-

[링크 : https://stackoverflow.com/questions/20436466/lsb-to-msb-bit-reversal-on-arm]

 

RBIT
Reverse the bit order in a 32-bit word.

Syntax
RBIT{cond} Rd, Rn

[링크 : https://developer.arm.com/documentation/dui0473/m/arm-and-thumb-instructions/rbit]

 

REV
Reverse the byte order in a word.

Syntax
REV{cond} Rd, Rnn

[링크 : https://developer.arm.com/documentation/dui0473/m/arm-and-thumb-instructions/rev]

'embeded > ARM' 카테고리의 다른 글

i.mx8m plus arm trust zone  (0) 2023.02.24
ampere altra / 기가바이트 R272-P30 / 우분투  (0) 2023.02.03
vfp, neon cycle  (0) 2022.01.23
cortex-a9 neon  (0) 2021.06.21
EIM (external interface module)  (0) 2021.06.21
Posted by 구차니