2020年10月11日 星期日

MikroTik RouterOS 設定 NAT

WebFig進入點: IP>FireWall>NAT頁面

Chain: dstnt
Protocol: 6(tcp)
Dst. Port: AAAA-BBBB
Dst.Address type: local
Action: dst-nat
To Address: 192.168.88.NNN
To Port:AAAA-BBBB

2020年10月1日 星期四

[ESP32] Using the MFRC522 RFID reader and SD card reader

Today some guy in the Facebook proposed an interesting problem about how to use the RFID and the SD in ESP32s .  Both peripheral devices used the SPI connections. The point is they need it's own CS (chip select) pin to enable the SPI (MOSI/MISO/CLK) bus. Only one of them can be enabled in the same time because the enabled device will occupy the SPI bus.

Uusing the original SD ReadWrite code of the arduino example, we could find it's failed even if the CSs are defined well. To see what happened, I checked the compiler messages, as the following:

Use library SPI、verison 1.0,in folder:C:\Users\user\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4\libraries\SPI
Use library SD、version 1.0.5,in follder:C:\Users\user\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4\libraries\SD
Use library FS、version 1.0,in folder:C:\Users\user\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4\libraries\FS

From the view point of the software architecture, the SD layer is stacked above the FS which is stacked on the SPI hearware driver. The above messages showed that ESP32 SD library was applied, which caused the original SD ReadWrite code to be failed. 

To solve the problem, some library definition are to be modified as the follows.

2020年7月11日 星期六

C# WebRequest 連接 https 發生 SSL 錯誤

這個問題在 .Net 4.5 以前無法自動切換至 SSL, 問題在於憑證的驗證, 網路上有許多做法, 不過現在最簡單的方法, 就是改成 .Net 4.6以上的版本就可以了,  預設使用 TLS1.2, 如果網站 TLS 版本不符, 用 ServicePointManager 指定版本就好

https://docs.microsoft.com/zh-tw/dotnet/framework/network-programming/tls

2020年7月8日 星期三

設定Windows排程器執行powershell script




在Windows排程器中編輯動作:

程式或指令碼: powershell
新增引數: -ExecutionPolicy Bypass -File "C:\RmtRuntime\rmt_zip_daily.ps1"




這裡必須指定 -ExecutionPolicy Bypass 才可執行

以下為 rmt_zip_daily.ps1 的內容
--------------------------------------------
#REQUIRES -Version 2

$ZipDate = [DateTime]::Today.AddDays(-1).ToString("yyyy-MM-dd")

$SourceFile = "D:\TempRMT\Source2020\$ZipDate.zip"
if (Test-Path $SourceFile) {
  Remove-Item $SourceFile
}
7z a $SourceFile  "E:\RMT Processing\Source\$ZipDate"
copy $SourceFile  "\\NAS01\Temp\Backup\Google\RMT Processing\Source2020\$ZipDate.zip"



$Source20sFile = "D:\TempRMT\Source2020-20s\$ZipDate.zip"
if (Test-Path $Source20sFile) {
  Remove-Item $Source20sFile
}
7z a $Source20sFile "E:\RMT Processing\Source20s\$ZipDate"
copy $Source20sFile "\\NAS01\Temp\Backup\Google\RMT Processing\Source2020-20s\$ZipDate.zip"

2020年6月28日 星期日

[tensorflow] 在v2下使用v1

tenserflow 2版之後有許多功能已經跟 v1不相容, 幸好 v2 包含了 v1 的方法, 只是改了類別名稱, 如果原有 v1 的程式碼想要在 v2 環境使用, 只要照以下 import 方式就可以繼續使用原 v1 程式碼:

import tensorflow.compat.v1 as tf
tf.disable_v2_behavior() 

2020年6月16日 星期二