2017年7月27日 星期四

Free e-book

English
========================================================================
I google from the web and find a useful web site for sharing e-books.

Here is a link.



中文
========================================================================
網路發現免費電子書網站,分享給大家,網址

2017年7月17日 星期一

C# Compiler Error list

English
========================================================================

This web site talk about the error code when you build the Visual Studio project.

Reference: https://docs.microsoft.com/zh-tw/dotnet/csharp/language-reference/compiler-messages/cs0246




中文
=======================================================================

紀錄一下 Visual Studio 在 build 所產生的 錯誤碼

Ref: https://docs.microsoft.com/zh-tw/dotnet/csharp/language-reference/compiler-messages/cs0246

2017年4月6日 星期四

C# Localizing Windows Forms 將 Windows Form 當地語系化

English==================================================================

Hi all, today I will share how to let a application UI support device's UI language.

1. Open Visual Studio 2015 and select Windows Forms Application.

2. Add a button in Form1.

3. Set Localizable be true and Language be English. These settings are in Form1's Properties. Set the Button1's text be Hi.


4. Set Language be French in Form1's Properties and set the Button1's text be Bonjour.


5. Set Language be Chinese (Traditional) in Form1's Properties and set the Button1's text be 哈囉.


6. Click the Show All Files button in Solution Explorer. You can see there are many resource file in Form1.cs


7. Run the application. You can see the text is reference by your PC.



Reference: Walkthrough: Localizing Windows Forms.



中文====================================================================

今天要分享如何讓程式畫面可以顯示本機系統的語言

1. 首先打開 Visual Studio 2015,選擇 Windows Forms Application.

2. 在 Form1 中加入一個 Button

3. 在 Form1 內 Properties 中,設定 Localizable 為 True,並設定 Language 為 English,並更改 Button1 的 Text 為 Hi


4. 在 Form1 內 Properties 中,設定 Language 為 French,並更改 Button 的 Text 為 Bonjour


5. 在 Form1 內 Properties 中,設定 Language 為 Chinese (Traditional),並更改 Button 的 Text 為 哈囉


6. 建立專案,在 Solution Explorer 選擇 Show All Files,可以從這邊看到 Form1 有許多 *.resx 檔案,這就是對應不同作業系統所需的資源檔


7. 實際執行程式,會發現 Button 所顯示的文字會根據作業系統而變動 (測試系統環境為繁體中文)




Reference: Walkthrough: Localizing Windows Forms.

2016年9月25日 星期日

UWP IoT Core shutdown device 關機

English
========================================================================
Today we will implement the shutdown function on Win 10 IoT Core.

1. Add below code in Package.appxmanifest file.

2. Add reference named "Windows IoT Extensions for the UWP" in project.

3. Add using and below code in project.


4. The device will shutdown when button click.



中文
========================================================================
今天要在 Win 10 IoT Core 上實現關機的動作。

1. 首先要開啟權限,打開 Package.appxmanifest 檔案,加入以下程式碼。

2. 加入名為 "Windows IoT Extensions for the UWP" 參考進入專案中。

3. 加入使用和以下程式碼至 MainPage.xaml.cs。


4. 當按鈕按下後,就會進行關機的動作。

2016年9月1日 星期四

Win10 IoT Core connect to the Ethernet by 3G card (Quectel UC20G) 網卡連線

English
========================================================================
Today I'll introduce how to connect on ethernet by using Quectel UC20G 3G card.

1. Run the “Windows PowerShell ISE” with administrator privileges.

2. Enter below commands to link with IoT Core device. Before this step, you need to turn on the IoT Core device and make it on the ethernet to get it's IP. The below commands will remote control the IoT Core device with administrator privileges.

    2-1 Net start WinRM.
    2-2 Set-Item WSMan:\localhost\Client\TrustedHosts -Value device'sIP.

    2-3 Enter-PSSession device'sIP -Crendential device'sIP\administrator.

3. Enter below commands to get SIM card's info.
    3-1 Netsh mbn show ready *

4. Enter below commands to line up UC20G. You need to modify the profile values. After modify the profile, you need to copy it to your USB storage and insert the USB storage to IoT Core device.

       4-1 Netsh mbn add profile interface="Cellular" name="D:\profile.xml"

       4-2 Netsh mbn connect interface="Celluar" connmode=name name="Quectel Wireless Ethernet Adapter"

5. You can see the UC20G is line up



中文
========================================================================
今天我們要在 Win 10 IoT Core 上,使用 Quectel UC20G 網卡進行連線的實作。

1. 使用管理者身分執行 PowerShellISE

2. 輸入以下的命令,連線到 IoT Core 裝置上
        2-1 Net start WinRM
        2-2 Set-Item WSMan:\localhost\Client\TrustedHost - Value device'sIP
        2-3 Enter-PSSession device'sIP -Crenditial device'sIP\administrator

3. 輸入以下命令去讀取 SIM 卡資訊
        3-1 Netsh mbn show ready *

4. 修改連線所需的 Profile.xml,並使裝置連線

        4-1 Netsh mbn add profile interface="Cellular" name="D:\profile.xml"

        4-2 Netsh mbn connect interface="Cellular" connmode=name name="Quectel Wireless Ethernet Adapter"

5. 透過網頁可以看到 UC20G 連線成功

2016年8月28日 星期日

Win10 IoT Core initial SHT21 Zigbee device 實作 SHT21 Zigbee 裝置

English
========================================================================
Today I'll implement the SHT21 Zigbee device on IoT Core image.

1. Find out the Zigbee device VID and PID. You can insert the Zigbee device on your PC to find the VID and PID.

2.Check currently available USART.

3. Assign USART interface with port name and set USART interface as “Removable”.

4. Restart device and run MS serial sample. You’ll see the USART is ok.



中文
========================================================================
今天我要實作 SHT21 Zigbee 裝置在 Win 10 IoT Core 上。

1. 先找出 Zigbee 裝置的 PID 和 VID,可以先把 Zigbee 裝置裝到PC上,使用裝置管理員查詢。



2. 使用 PowerShellISE 去檢查裝置狀態

3. 分派 Zigbee 裝置為 COM5 並設定為卸除式裝置

4. 重開裝置後,開啟微軟 Serial sample 程式,你會看到 Zigbee 的 COM port 設定完成。

2016年7月22日 星期五

Win 10 IoT Core specify USART on our device (Export Serial.sys COM ports) 實作 COM 在自家板子上

English
========================================================================
I use Bay-trail platform device to implement the COM with MBM image.

1. Connect to target device by SSH connection.

2. Check currently available USART interface by using "devcon" command.
ssh> devcon status *pnp0501

ACPI\PNP0501\0
    Name: Communications Port
    Driver is running.
ACPI\PNP0501\1
    Name: Communications Port
    Driver is running.

2 matching device(s) found.

3. Specify USART interface. (In below command, I try to assign port 0 be named "SER1:")
ssh> reg add "HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\enum\acpi\pnp0501\0\Device Parameters" /v PortName /t REG_SZ /d "SER1"


The operation completed successfully.

4. Set USART interfaces as removable.
ssh> reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\DeviceOverrides\*PNP0501\LocationPaths\*" /v Removable /t REG_DWORD /d 1


The operation completed successfully.

5. Reboot system to make above settings effective.
ssh> shutdown /r

6. Use GitHub sample code to check the USART are correct.





中文
========================================================================
使用 Bay-trail 平台的板子,使用 MBM image,實作 COM 的初始化。

1. 使用 SSH 連線至 device

2. 輸入"devcon status *pnp0501"

ssh> devcon status *pnp0501

ACPI\PNP0501\0
    Name: Communications Port
    Driver is running.
ACPI\PNP0501\1
    Name: Communications Port
    Driver is running.

2 matching device(s) found.

3. 新增以下機碼去註冊 COM port (以下機碼是初始化 port 0 並命名為"SER1")
ssh> reg add "HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\enum\acpi\pnp0501\0\Device Parameters" /v PortName /t REG_SZ /d "SER1"


The operation completed successfully.

4. 新增以下機碼,設定為可卸除式裝置
ssh> reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\DeviceOverrides\*PNP0501\LocationPaths\*" /v Removable /t REG_DWORD /d 1


The operation completed successfully.

5. 重開機讓設定啟動
ssh> shutdown /r

6. 使用 GitHub 上的範例程式去測試是否成功掃到 COM ports。



OS Operating System 作業系統 恐龍書 筆記分享

發現一個作業系統說明的網站, 對於 process vs thread, semaphore vs mutex, deadlock 說明很詳細, 有興趣的人可以去以下的網頁逛逛。 附上網址連結: link   link2