2025年8月3日 星期日

在windows中用Visual Studio Code開啟Claude AI

在windows10/11中用Visual Studio Code開啟Claude AI,
可以直接用Claude寫code.


前置作業, 要先安裝好wsl在windows作業系統裡.

1. 到要給Claude操作的目錄下.


2025年5月25日 星期日

[Linux] User space 函式庫

●Delay 
#include <unistd.h>
usleep(100000); // 延遲 100,000 微秒 = 100 毫秒

●Delay 
#include <time.h>
struct timespec ts;
ts.tv_sec = 0;
ts.tv_nsec = 100 * 1000000L; // 100 毫秒
nanosleep(&ts, NULL);

2025年5月11日 星期日

[網路] 如何判斷Bandwidth


2.4G
HT Capabilities Bit 1(Supported Channel Width Set)
0: 20, 1: 20/40


如果Supported Channel Width Set,有可能是20或40
所以要再看Secondary Channel Offset


STA Channel Width   Secondary Channel Offset說明
0    0     使用 20 MHz
1    1(Above)     使用 40 MHz,副頻道在上面
1    3(Below)     使用 40 MHz,副頻道在下面

2024年12月14日 星期六

[Linux] hostapd create nelink socket和kernel driver溝通

1. static struct nl_sock * nl_create_handle(struct nl_cb *cb, const char *dbg)

2. struct nl_sock *nl_socket_alloc_cb(struct nl_cb *cb)
  a. calloc struct cb memory area
  b. 建立pid s_local.nl_pid = generate_local_port(); //取process id作為pid

3. 在此建立socket和bind
int genl_connect(struct nl_sock *sk)
  a. sk->s_fd = socket(AF_NETLINK, SOCK_RAW | flags, protocol);
  b. bind(sk->s_fd, (struct sockaddr*) &sk->s_local, sizeof(sk->s_local));

2024年10月22日 星期二

[網路] BSSID

BSSID: WiFi AP的MAC Address.

SSID: WiFi AP beacon發出來的名字,就是在wifi收尋選單看到的名字.

2024年8月19日 星期一

[網路] 如何判斷WPA3 SAE和WPA2 PSK/WPA3 SAE mix mode

主要是看beacon的RSN information tag


根據chatgpt解說

Identifying WPA2 vs. WPA3

  • WPA2: The AKM suite typically includes entries such as 00-0F-AC-1 (PSK) or 00-0F-AC-2 (802.1X).
  • WPA3: The AKM suite for WPA3 will include:
    • SAE (Simultaneous Authentication of Equals): 00-0F-AC-8, indicating WPA3-Personal.
    • Suite B: 00-0F-AC-9, indicating WPA3-Enterprise, often used with 192-bit cryptographic strength


2024年6月29日 星期六

[Linux] fclose close /proc下檔案導致當機

/proc is a virtual file system
 
//From chatgpt  
在 Linux 中,/proc 文件系統是一個虛擬文件系統,提供了訪問內核數據結構的接口,/proc 下的文件並不是真正的磁盤文件,而是由內核動態生成的,這些文件的行為可能與普通文件有所不同,尤其是在處理方式上.

在/proc除了是虛擬文件系統,裡面的檔案可能有其他process matain,也就是說有其他process 在操作此檔案,那fclose就可以free到錯誤的memory address

有時候在/proc的檔案大小還會是0






如果要讀取fopen /proc下檔案,把它導到 /tmp下再操作,即可避免當機問題.

[OpenWRT] Missing lto (liblto_plugin.so)

1. 少了lto
plugin needed to handle lto object
這其實是一個error,但卻沒顯示error,還把.a建出來,他的意思是組libubusd_library.a時找不到liblto_plugin.so
[ 62%] Linking C static library libubusd_library.a
toolchain-aarch64_xxx/bin/aarch64-openwrt-linux-ar: CMakeFiles/ubusd_library.dir/ubusd.c.o: plugin needed to handle lto object
toolchain-aarch64_xxx/bin/aarch64-openwrt-linux-ar: CMakeFiles/ubusd_library.dir/ubusd_proto.c.o: plugin needed to handle lto object
toolchain-aarch64_xxx/bin/aarch64-openwrt-linux-ar: CMakeFiles/ubusd_library.dir/ubusd_id.c.o: plugin needed to handle lto object

2024年4月20日 星期六

2023年11月5日 星期日

[Win10] 開啟休眠選項

開啟消失的休眠選項

1. 命令提示字元(系統管理員)
2. C:\WINDOWS\system32>powercfg /H on

2023年9月1日 星期五

[C][string] strtok/strtok_r 字串切割

字串切割 
string tokenization

#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int main(int argc, char **argv)
{
    const char * const str = "MAC-:AA-BB-CC-DD-EE-FF";
    const char * const delimitation = "-:";
    char * const dupstr = strdup(str);
    char *saveptr = NULL, *substr = NULL;
    int i = 0;

    printf("original: %s (%p)\n", dupstr, dupstr);
    
    substr = strtok_r(dupstr, delimitation, &saveptr);

    do {
        printf("#%d after parsing: %s (%p)\n", i++, substr, substr);
        substr = strtok_r(NULL, delimitation, &saveptr);
    } while (substr);
    
}

/*
[Result]
original: MAC-:AA-BB-CC-DD-EE-FF (0x55f73e1e42a0)
#0 after parsing: MAC (0x55f73e1e42a0)
#1 after parsing: AA (0x55f73e1e42a5)
#2 after parsing: BB (0x55f73e1e42a8)
#3 after parsing: CC (0x55f73e1e42ab)
#4 after parsing: DD (0x55f73e1e42ae)
#5 after parsing: EE (0x55f73e1e42b1)
#6 after parsing: FF (0x55f73e1e42b4)
*/


[C][string] strstr/strchr用法

在字串中找特定字

eq,
在”ABCDEF”中找”CD” → 用strstr,不能用strchr,記憶體會壞掉
在”ABCDEF”中找’C’ → 用strchr,也可以用strstr

[C][string] sscanf用法

#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int main()
{
   int day, year;
   char weekday[20], month[20], tmp[100];

   strcpy(tmp, "Saturday March aaa 25 1999");
   
   /*"%*s" means ignore aaa*/
   sscanf(tmp, "%s %s %*s %d %d", weekday, month, &day, &year);

   printf("%s %d %d %s", month, day, year, weekday);
    
   return(0);
}

/*
[Result]
March 25 1999 Saturday
*/
%*s 表示可以忽略字串的中aaa


2023年5月23日 星期二

[OpenWRT] 開啟curl中的SCP和sftp功能

官網中提到要開啟此功能需要載入libssh2, libssh
https://everything.curl.dev/usingcurl/scpsftp


1. config
CONFIG_PACKAGE_libssh=y
CONFIG_PACKAGE_libssh2=y

2. make menuconfig
Libraries → libcurl → SCP / SFTP protocol


3.
這樣make時才會帶入在makefile中的--with-libssh2=/usr/local


2023年3月26日 星期日

[Win10] 更新後藍牙不能用(消失)

檢查裝置管理後發現藍芽消失了,且藍芽滑鼠失效

正常情況應為下圖所示,


此時反倒出現了一個為未知裝置


按右鍵,把他移除,重新機後,藍芽就恢復正常