自己用來測試串列埠的一些函式
1#使用 powershell 測試串列埠資料23
#列出有對外使用價值的函式
4function
showfunctions()513
14#列出串列埠列表
15function
listportnames()
161920#
獲取 serialport 物件, 例:21#
getport com3,9600,none,8,one 100022#
portsetting : 串列埠引數, 例: com3,9600,none,8,one23#
readtimeout : 讀資料超時毫秒數, 例: 1000, 在 1 秒內沒有讀到資料就產生異常24#
得到的物件需要呼叫 open 方法, 之後傳送資料
25function getport($portsetting, $readtimeout)26
3233
#關閉串列埠
34function closeport($port)35
3940
#傳送接收和顯示位元組41#
hexstring 16進製表示的位元組值字串,以空格分割資料, 例: 01 02 0f
42function sendreceiveanddisplaybytes($port, $hexstring)43
5051#傳送
52$bytes4send = converttobytearray $hexstring;53
$port.write($bytes4send, 0, $bytes4send
.length);
5455 start-sleep -milliseconds 100;
5657#接收
58$recvbuffer = new-object byte 128;
59$recvlen = $port.read($recvbuffer, 0, 128);
6061#顯示
62 write-host -nonewline 'receive: ';
63 converttohex $recvbuffer 0 $recvlen | write-host;
6465
return
'done';66}
6768
#將16進位制字串轉換成位元組陣列
69function converttobytearray($hexstring)70
79return
$result;80
}8182#
bytes 要顯示的位元組陣列, 83#
offset 從第一個位元組起的偏移量,84#
count 在位元組陣列中讀取的長度,85#
byte to hex string : 86#
a) [system.convert]::tostring($bytes[$i], 16);87#
b) abyte.tostring("x2") // 小於16會加一個0, 形如: 0e
88function converttohex($bytes, $offset, $count)89
94return
$result
;95 }
--------- the end ---------
Powershell
測試發現360 不攔截 powershell 本身的執行 攔截的是其它程序對 powershell exe 的呼叫 以mshta為例 html meta http equiv content type content text html charset utf 8 head script langu...
Powershell findstr
從檔案中找出關鍵字 colitems get childitem d test 定義資料夾的路徑 foreach i in colitems...
Windows Powershell
首先整理下這幾個概念 dos是指作業系統 在windows95之前 ,這個相信都知道。 cmd 命令提示符 ,是在windows下面模擬的dos環境 ,能執行絕大部分dos命令 包含c windows system32 裡的可執行檔案 如net exe ftp exe tftp exe taskmg...