2020-06-29

Generate a file nv2808.xml

寫入資料到 nv-2808.xml。
Source code 搬到 github


一個小工具。 XQCN 是 Qualcomm 使用的檔案格式,用來記錄 RF 相關的資料。其中 NV 2808 被用來設定為軟體版本的資訊(如果有使用的話)。

舉例來說,如果一個案子叫 FIREBIRD,地區是給北美 (NA) 使用的,目前的開發進度在 MP1,目前的版本是第一版,版本號就是 FIR_NA_MP1_001。這個工具就是用來產生 NV2808 的資料。

一般而言整合的方法有二個方式,第一個是將 NV-2808.xml 轉成 XQCN 檔案再使用 Qualcomm 提供的工具整合,第二個方式是將原始的 QCN 檔案轉為 NV XML 檔案,和 NV-2808.xml 整合以後再使用 Qualcomm 提供的工具轉為 XQCN 檔案。

總之,如果 XQCN 檔案也有放到版本管理中(例如 git),最終成品需要有版本號碼才行,用這樣的方式做 XQCN 檔案版本控管。

2020-06-06

Tcl: Hidden Squares

一個 string first 的範例,用來取得 Hidden Squares 問題的解:
#!/usr/bin/tclsh
#
# Hidden Squares:
# A number n may have squares hidden among its digits. For instance, 
# in the number 1625649, the consecutive digits 1, 4, 9, 16, 25, 49, 
# 64, 256 and 625 are all squares.
#

namespace path {::tcl::mathop ::tcl::mathfunc}

puts -nonewline "Please input a number: "
flush stdout
gets stdin number
if {$number <= 0} {
    puts "Number requires > 0."
    exit
}

set max [int [sqrt $number]]
for {set i 1} {$i <= $max} {incr i} {
    set n [* $i $i]
    if {[string first $n $number] >= 0} {
        puts -nonewline "$n "
    }
}
puts ""

這裡也使用了 namespace path。

Tcl 支援 namespace 的概念,一個 namespace 是 function 和變數的集合,和  C++ 類似,透過封裝可以保證不會被其它的 namespace 的變數和命令所影響,而且你可以隨時新增、改名與刪除裡面的成員。