2024年3月18日 星期一

[secs]HSMS timeout

 T6: Active 端

    select.req <-T6-> select.rsp

T7: Passive 端

    open -> not_select <-T7-> select

T5: Active 端

    connect_fail <-T5-> connecting

T8: msg:{B <-T8-> B...}

2024年3月7日 星期四

[csharp]C# 如何得知某個 class 有實作某個介面

 ## 方法

1. objectType.GetInterfaces().Contains(interfaceType)


2. interfaceType.IsAssignableFrom(objectType)


3. objectType.IsAssignableTo(interfaceType)


4. objectType.GetInterface(nameof(interface)) != null


## 參考來源

https://www.facebook.com/groups/1706638306295947/?multi_permalinks=3338835626409532

2024年1月7日 星期日

[vmware]突然出現 misc.rsba_no 不存在的問題

 是否出現 misc.rsba_no 不存在的問題?其實解答不是表面上可以看到的。


我最近突然遇到很多個 suspend 的 vm 開起來就出現這個問題,導致許多暫存的東西皆無法回復。


回頭去查發現這情況都發生在主機的 hyper-v 功能打開之後,來回測試一番,覺得應該是 CPU 特性有改變,讓 vmware 無法回復狀態。


很重要的資料在 vm 裡沒存的話,還是改回去做處理。

2023年12月19日 星期二

[C#]C# 最近出現的 ? ! 是做什麼用的?

 C# 最近出現的 ? ! 是做什麼用的?


最近終於找到一個圖快速介紹這些?!是做什麼用的。


主要是用以解決 null 相關的問題的語法糖


https://twitter.com/mwaseemzakir/status/1647856976477450240/photo/1


Ternary Operator (?:)

Null Forgiving Operator (!.)

Null Conditional Operator (?.)

Null Coalescing Operator (??)

Null Coalescing Assignment Operator (??=)

2022年12月14日 星期三

[DDS]Vortex Opensplice 建議跳槽到 Cyclone DDS

> We, therefore, encourage the Vortex Opensplice open source community users to consider migrating to Cyclone DDS.

看到就準備要跳了喔 


https://github.com/ADLINK-IST/opensplice


For more than a decade, the Vortex Opensplice open source project helped to evangelise and successfully deploy the OMG Data Distribution Service Technology in thousands of industrial and academic projects worldwide. The Vortex Opensplice core team and the community have gained tremendous experience and know-how from these interactions.


Capitalizing on our lengthy experience developing data-centric middleware in real-time distributed systems the core team launched Cyclone DDS, a brand-new open source OMG DDS implementation. Cyclone DDS under the Eclipse foundation governance continues our mission to fuel innovation and serve a more diverse customer base. It is gaining momentum in many opensource frameworks and industrial contexts including ROS2 , Autoware etc. It also represents a genuinely open-source data distribution solution with full source code access and updates.


Buoyed by this success and adoptions, it became obvious that the focus of the core team and the community should now be Cyclone DDS. We, therefore, encourage the Vortex Opensplice open source community users to consider migrating to Cyclone DDS. The migration is straightforward when the ISO CPP V2 APIs are in use. For users that are building mission- and/or business-critical systems, ADLINK continues to support Vortex Opensplice Professional Edition and offers a commercially supported version with extra features and guarantees of support.

2022年10月30日 星期日

[arduino]Arduino IDE 2.0 強制設定為英文介面

 Arduino IDE 1.x 是以 Java 為基底。而 Arduino IDE 2.0 則是以 Javascript 為基底。


仔細的說,Arduino IDE 2.0 是以 node.js(後端) + Chromium(前端) 建構的 electron 架構為底。同樣使用 electron 為架構的有 vscode。(歷史的眼淚,開始是 github 用來做 atom 編輯器,在2022年6月8號,GitHub正式宣布在2022年12月15日關閉Atom,並存檔其儲存庫[by wiki]。)


好處是,近年來的 js 前端風潮,投入的人真的比較眾多且新鮮。進展也許真的會快很多,UI/UX 是真的不一樣。


現在對於 zh-tw 的翻譯還沒有完善,在我的電腦上,有些地方會使用到 zh-cn。如果像我這麼龜毛要處理的話,暴力處理就是強制使用 en,有兩個地方要處理。


  1. 在 menu 上的中文要變英文,超暴力方法,執行檔目錄裡的 locales 目錄,底下除了 en-US.pak 之外的都殺掉。
  2. 在 output 裡的 message 不要看到中文,在 C:\Users\<User>\.arduinoIDE 底下的 arduino-cli.yaml 內容第一行,加上 locale: en <換行>


這樣就可以全部都變英文。

2022年10月7日 星期五

[小知識]從 arduino 學到 NTP packet

 NTP 是網路對時的協定,在一般因為是作業系統自動處理,所以也不知到哪裡找資訊。

反而因為 arduino 這類 MCU 興起的關係,很多老協定的原始碼與 SPEC 就有了關鍵字可以深探與學習。

重點

* UDP 傳送,48 BYTE,UTC時間

兩段重點程式

```

unsigned long sendNTPpacket(IPAddress& address) {

    Serial.println("sending NTP packet...");

    // set all bytes in the buffer to 0

    memset(packetBuffer, 0, NTP_PACKET_SIZE);  //clear the buffer

    //Initialize values needed to form NTP request

    //(see URL above for details on the packets)

    packetBuffer[0]=0b11100011;   // LI, Version, Mode

    packetBuffer[1]=0;     // Stratum, or type of clock

    packetBuffer[2]=6;     // Polling Interval

    packetBuffer[3]=0xEC;  // Peer Clock Precision

    //8 bytes of zero for Root Delay & Root Dispersion

    packetBuffer[12]=49;

    packetBuffer[13]=0x4E;

    packetBuffer[14]=49;

    packetBuffer[15]=52;

    // all NTP fields have been given values, now

    // you can send a packet requesting a timestamp:

    udp.beginPacket(address, 123); //NTP requests are to port 123

    udp.write(packetBuffer, NTP_PACKET_SIZE); //send UDP request to NTP server

    udp.endPacket();

    }

```


```

unsigned long getUnixTime() {

    WiFi.hostByName(ntpServerName, timeServerIP);  //get a random server from the pool

    sendNTPpacket(timeServerIP);                   //send an NTP packet to a time server

    delay(1000);                                   // wait to see if a reply is available


    int cb=udp.parsePacket();                      //return bytes received

    unsigned long unix_time=0;

    if (!cb) {Serial.println("no packet yet");}

    else {  //received a packet, read the data from the buffer

        Serial.print("packet received, length=");

        Serial.println(cb);                        //=48

        udp.read(packetBuffer, NTP_PACKET_SIZE);  //read the packet into the buffer


        //the timestamp starts at byte 40 of the received packet and is four bytes,

        //or two words, long. First, esxtract the two words:

        unsigned long highWord=word(packetBuffer[40], packetBuffer[41]);

        unsigned long lowWord=word(packetBuffer[42], packetBuffer[43]);

        //combine the four bytes (two words) into a long integer

        //this is NTP time (seconds since Jan 1 1900):

        unsigned long secsSince1900=highWord << 16 | lowWord;

        Serial.print("Seconds since Jan 1 1900=" );

        Serial.println(secsSince1900);

        Serial.print("Unix time=");

        //Unix time starts on Jan 1 1970. In seconds, that's 2208988800:

        unix_time=secsSince1900 - 2208988800UL;

        Serial.print(F("Unix time stamp (seconds since 1970-01-01)="));

        Serial.println(unix_time); //print Unix time

        }  

    return unix_time; //return seconds since 1970-01-01

    }

```


參考

* [Arduino C on ESP8266 學習筆記 (三) : 從 NTP 伺服器取得網路時間](http://yhhuang1966.blogspot.com/2017/09/arduino-ide-esp8266-ntp.html)