-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathserialCall.ps1
More file actions
45 lines (37 loc) · 827 Bytes
/
serialCall.ps1
File metadata and controls
45 lines (37 loc) · 827 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
param([string]$number = '')
# Enter PSScriptRoot
cd $PSScriptRoot
# Init
. "$PSScriptRoot\init.ps1"
# Import config
. "$PSScriptRoot\config.ps1"
# Model configuration
if ($Model -eq "A6PRO") {
$Syntax = " `r"
}
elseif ($Model -eq "SIM800") {
$Syntax = ""
}
elseif ($Model -eq "A7670E") {
$Syntax = "`r`n"
}
# Select USB port
Get-Port
try {
$port.Open()
$port.WriteLine("ATD$number;$Syntax")
Start-Sleep $CallDuration
$output = $port.ReadExisting()
foreach ($line in $output) {
if ($line.Contains("ERR")) {
Throw "ERROR IN COMMAND: $line"
}
}
}
catch {
Add-Content -Path $ErrLogFile -Value $("CALL [" + (LogFormat) + "] " + "`n" + $_.Exception.Message)
$port.Close()
Throw "ERROR FOUND $line"
}
$port.WriteLine("AT+CHUP$Syntax")
$port.Close()