-
Notifications
You must be signed in to change notification settings - Fork 0
/
Prog Assist.bat
1329 lines (1257 loc) · 33.7 KB
/
Prog Assist.bat
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
@echo off
mode con: cols=49 lines=30
title Programming Assistant
setlocal EnableDelayedExpansion
echo Loading . . .
Set version=Release-1.6
set autostart=on
set dontdisplaytrs=FALSE
if exist Bin\Settings.cmd call Bin\Settings.cmd
if %autostart%==on (
call Bin\CMDS.bat /ts "Prog Assistant COM Companion"
if !errorlevel!==1 cscript //B //Nologo "Bin\CMS.vbs"
)
REM TODO
rem 4. add auto github check on new vendor model
ping github.com -n 1 >nul 2>nul
if %errorlevel%==0 call :CheckForUpdates
:CancelUpdate
set lines=10
goto mainmenu
:titlebar
echo [90;7mF1-Menu F2-Updates F3-New Window F4-COMS F10-Quit[0m
echo =================================================[0m
exit /b
:Menutitlebar
echo [90;7mF1-Menu F2-Updates F3-New Window F4-COMS F10-Quit[0;96m
echo =================================================[0;7m
exit /b
:mainmenu
cls
echo =================================================[0;7m
call :Menutitlebar
if exist Bin\logo.ascii (
type Bin\logo.ascii
echo.
)
echo [0;96m=================================================[0m
echo 1] View Radio
echo 2] New Radio
echo 3] COM Ports
echo [90mS] Settings
echo U] Update Vendors, Radios, ^& Cables Online
echo X] Exit[0m
"Bin\kbd.exe"
if %errorlevel%==49 goto ViewRadio
if %errorlevel%==50 goto AddRadio
if %errorlevel%==51 goto COMS
if %errorlevel%==51 exit /b
if %errorlevel%==120 exit /b
if %errorlevel%==59 goto mainmenu
if %errorlevel%==60 goto Updates
if %errorlevel%==61 start "" "%~0"
if %errorlevel%==62 goto COMS
if %errorlevel%==115 goto settings
if %errorlevel%==52 goto settings
if %errorlevel%==117 goto updates
if %errorlevel%==68 exit /b
goto mainmenu
:updates
:UpdateLibrary
cls
if exist Bin\logo.ascii (
type Bin\logo.ascii
echo.
)
echo [0;96m=================================================[0m
set owner=W1BTR
set Didupdate=No
set repo=Programming-Assistant
echo [90mChecking repository for new vendors and radios...[93m
:: Get the JSON data from GitHub API and save it to a temporary file
curl -s -H "Accept: application/vnd.github.v3.raw" -L https://api.github.com/repos/%OWNER%/%REPO%/contents/Bin/Files/Vendors > temp.json
:: Use PowerShell to parse the JSON and output the names
for /f "delims=" %%i in ('powershell -Command "Get-Content temp.json | ConvertFrom-Json | ForEach-Object { $_.name }"') do (
if not exist "Bin\Files\Vendors\%%~i" (
echo. > "Bin\Files\Vendors\%%~i"
echo Added new Vendor: %%~i
set Didupdate=Yes
)
set Vendor=%%~i
set VendorURL=!Vendor: =%%20!
curl -s -H "Accept: application/vnd.github.v3.raw" -L https://api.github.com/repos/%OWNER%/%REPO%/contents/Bin/Files/Radios/!VendorURL! > "vendortemp.json"
for /f "delims=" %%l in ('powershell -Command "Get-Content vendortemp.json | ConvertFrom-Json | ForEach-Object { $_.name }"') do (
if not exist "Bin\Files\Radios\!Vendor!\%%~l" (
if not exist "Bin\Files\Radios\!vendor!" md "Bin\Files\Radios\!vendor!\"
set Radio=%%~l
set Radio=!Radio: =%%20!
curl -# -H "Accept: application/vnd.github.v3.raw" -L https://api.github.com/repos/%OWNER%/%REPO%/contents/Bin/Files/Radios/!vendorURL!/!Radio! -o "Bin\Files\Radios\!vendor!\%%~l"
echo Added New Radio: %%~nl
set Didupdate=Yes
)
)
)
echo [90mChecking repository for new cables...[93m
del /f /q vendortemp.json
curl -s -H "Accept: application/vnd.github.v3.raw" -L https://api.github.com/repos/%OWNER%/%REPO%/contents/Bin/Files/Cables > temp.json
for /f "delims=" %%l in ('powershell -Command "Get-Content temp.json | ConvertFrom-Json | ForEach-Object { $_.name }"') do (
if /i not "%%~l"=="Owned" (
if not exist "Bin\Files\Cables\%%~l" (
set CableURL=%%~l
set CableURL=!CableURL: =%%20!
curl -# -H "Accept: application/vnd.github.v3.raw" -L https://api.github.com/repos/%OWNER%/%REPO%/contents/Bin/Files/Cables/!CableURL! -o "Bin\Files\Cables\%%~l"
echo Added New Cable: %%~nl
set Didupdate=Yes
)
)
)
:: Clean up temporary file
del temp.json
if %didupdate%==Yes (
echo [92mUpdates Installed.[0m
) ELSE (
echo [92mLibrary was up to date.[0m
)
pause
goto mainmenu
:CheckForUpdates
set OWNER=W1BTR
set REPO=Programming-Assistant
curl -s -H "Accept: application/vnd.github.v3+json" -L https://api.github.com/repos/%OWNER%/%REPO%/releases/latest | find /i "%version%" >nul 2>nul
if %errorlevel%==0 exit /b
cls
echo [95mAn Update is Available.[90m
curl -s -H "Accept: application/vnd.github.v3.raw" -L https://api.github.com/repos/%OWNER%/%REPO%/contents/Bin/Release.bat -o Release.bat
call Release.bat Info
echo [0mRun Update now?[0m
choice
if %errorlevel%==2 goto CancelUpdate
echo Installing update . . .
call Release.bat Install
echo Update failed.
pause
goto CancelUpdate
:settings
if %autostart%==on (
set ascolor=[92m
) ELSE (
set ascolor=[91m
)
cls
echo Settings Menu
echo --------------------
echo 1] COM Assistant Autostart: [%ascolor%%autostart%[0m]
echo X] Exit
choice /c 1x
if %errorlevel%==1 (
if %autostart%==on (
set autostart=off
goto savesettings
) ELSE (
set autostart=on
goto savesettings
)
)
goto mainmenu
:savesettings
(echo set autostart=%autostart%)>Bin\settings.cmd
goto settings
:COMS
set check=30
set selectedPort=1
if %autostart%==off (
call Bin\CMDS.bat /ts "Prog Assistant COM Companion"
if !errorlevel!==1 cscript //B //Nologo "Bin\CMS.vbs"
)
:COMLoop
set num=0
set linecount=0
cls
if not exist "Bin\COMLOG.log" goto :loadCOMLOG
call :menutitlebar
if exist Bin\logo.ascii (
type Bin\logo.ascii
echo.
)
echo [0;96m=================================================[0m
echo.
echo COM PORTS:
for /f "tokens=1,2,3 delims=, skip=1" %%A in ('type "Bin\COMLOG.log"') do (
set /a linecount+=1
set /a num+=1
set COMPort!num!=%%~A
set descrp=%%~B
if "!num!"=="!SelectedPort!" (
set comcolor=[7m
) ELSE (
set comcolor=
)
if "%%~C"=="True" (
echo !comcolor![92m%%~A [0m!comcolor!!descrp:~0,38! [90mNEW[0m
) ELSE (
echo !comcolor![96m%%~A [0m!comcolor!!descrp:~0,38![0m
)
)
copy /y "Bin\COMLOG.log" "Bin\COMLog.diff" >nul 2>nul
set check=30
:comKBDLoop
"Bin\Kbd.exe" 1
set /a check-=1
if %check%==0 (
fc "Bin\COMLOG.diff" "Bin\ComLog.log" >nul 2>nul
if !errorlevel!==1 goto COMLoop
set check=30
goto comKBDLoop
)
if %errorlevel%==0 goto comKBDLoop
if %errorlevel%==110 goto newvendor
if %errorlevel%==27 goto comstomainmenu
if %errorlevel%==120 goto comstomainmenu
if %errorlevel%==59 goto comstomainmenu
if %errorlevel%==60 goto Updates
if %errorlevel%==61 start "" "%~0"
if %errorlevel%==62 goto COMS
if %errorlevel%==68 exit /b
set _errorlevel=%errorlevel%
rem if %_errorlevel%==59 goto options
if %_errorlevel%==80 (
if not !SelectedPort! GEQ !linecount! (
set /a SelectedPort+=1
)
)
if %_errorlevel%==72 (
if not !SelectedPort! LEQ 1 (
set /a SelectedPort-=1
)
)
if %_errorlevel%==13 goto SelectedCOM
goto comloop
:loadCOMLOG
echo Loading . . .
:loadcomlogloop
if not exist "Bin\COMLOG.log" goto loadcomlogloop
goto comloop
:comstomainmenu
if %autostart%==off (
call Bin\CMDS.bat /tk "Prog Assistant COM Companion"
)
goto mainmenu
:SelectedCOM
cls
mode !COMPort%SelectedPort%! | more
mode !COMPort%SelectedPort%! | find /i "Not Available" >nul 2>nul
if %errorlevel%==1 (
echo 1] Change Setting [Baud, Parity, XON, etc]
echo 2] Enter Text Data into Port
echo 3] View Text Output
echo 4] Start a Putty Session
echo 5] Open Putty
echo 6] Pipe to Virtual Port [For Hypervisor]
echo X] Back
) ELSE (
echo X] Back
)
choice /c 123456X /n
if %errorlevel%==4 (
putty -serial !COMPort%SelectedPort%!
goto selectedcom
)
if %errorlevel%==5 (
putty -serial
goto selectedcom
)
if %errorlevel%==1 goto comsetting
if %errorlevel%==2 goto DataPort
if %errorlevel%==3 goto TypePort
if %errorlevel%==6 goto passthrough
goto COMS
:passthrough
if "%baudrate%"=="" set baudrate=19200
if "%PipeName%"=="" set PipeName=MyLittlePipe
cls
echo COM PIPE [howardtechnical.com] !COMPort%SelectedPort%!
echo [90mNOTE: This tool cannot create a named pipe,
echo it can only use an existing named pipe otherwise
echo a GLE error will occur.[0m
echo.
echo 1] Change Baud Rate [[96m%baudrate%[0m]
echo 2] Change Pipe Name [[90m\\.\pipe\[96m%PipeName%[0m\]
echo 3] [92mSTART PIPE[0m
echo X] Cancel
choice /c 123x
if %errorlevel%==1 (
echo.
echo Enter BAUD RATE:
set /p baudrate=">"
goto passthrough
)
if %errorlevel%==2 (
echo.
echo Enter Pipe Name:
set /p PipeName="[90m\\.\pipe\[0m"
goto passthrough
)
if %errorlevel%==3 (
echo set cd=%cd% >"%temp%\PASCD.cmd
echo set Port=!COMPort%SelectedPort%! >>"%temp%\PASCD.cmd
echo set name=\\.\pipe\%PipeName% >>"%temp%\PASCD.cmd
echo set baudrate=%baudrate% >>"%temp%\PASCD.cmd
powershell start -verb runas 'Bin\Piper.bat'
pause
goto SelectedCOM
)
goto SelectedCOM
:DataPort
echo Enter data to enter to port
set /p comcommand="!COMPort%SelectedPort%!>"
echo %comcommand%>!COMPort%SelectedPort%!
timeout /t 1 /nobreak >nul
goto selectedcom
:typeport
start "" "Bin\ViewCOM.bat" !COMPort%SelectedPort%!
goto selectedcom
:comsetting
echo Enter setting type followed by and equal
echo sign and it's value for example: BAUD=1200
echo Available Settings are:[90m
echo [BAUD=b] [PARITY=p] [DATA=d] [STOP=s]
echo [to=on|off] [xon=on|off] [odsr=on|off]
echo [octs=on|off] [dtr=on|off|hs]
echo [rts=on|off|hs|tg] [idsr=on|off][0m
echo Or enter X to cancel
set /p modecommand="!COMPort%SelectedPort%!>"
if /i "%modecommand%"=="X" goto SelectedCOM
mode %modecommand%
goto SelectedCOM
:ViewRadio
set Selected=1
set directory=Bin\Files\Radios
:SelectRadio
rem display a list of files in the Files\Vendors folder, allow the user to select one, and set the result to %vendor%
if "!Selected!"=="" set selected=1
set linecount=0
set item=0
set _skip=0
cls
call :titlebar
for /f "tokens=*" %%A in ('dir /b "!directory!"') do (
set /a linecount+=1
set /a item+=1
set _echo=%%~nA
if exist "!directory!\%%~A\*" set _echo=}%%~A
set /a _tmpVar=!selected!-!item!
if !_tmpVar! LSS 35 (
if "!Selected!"=="!item!" (
echo [7m!_echo![0m *
set "_SelectedFile=%%~A"
set "_SelectedExtension=%%~xA"
set "_SelectedName=%%~nA"
) ELSE (
echo !_echo!
)
) ELSE (
set /a _skip+=1
)
set /a _tmpVar=!linecount!-!_skip!
if !_tmpVar!==%lines% (
echo | set /p "= . . ."
goto 1BreakLoop1
)
)
:1BreakLoop1
"Bin\Kbd.exe"
if %errorlevel%==59 goto mainmenu
if %errorlevel%==60 goto Updates
if %errorlevel%==61 start "" "%~0"
if %errorlevel%==62 goto COMS
if %errorlevel%==68 exit /b
set _errorlevel=%errorlevel%
rem if %_errorlevel%==59 goto options
if %_errorlevel%==80 (
if not !Selected! GEQ !linecount! (
set /a Selected+=1
)
)
if %_errorlevel%==72 (
if not !Selected! LEQ 1 (
set /a Selected-=1
)
)
if %_errorlevel%==77 (
if exist "%directory%\%_SelectedFile%\*" goto RadioEnterPressed
)
if %_errorlevel%==75 (
if not "%directory%"=="Bin\Files\Radios" goto :SelectUpOne
)
if %_errorlevel%==8 (
if not "%directory%"=="Bin\Files\Radios" goto :SelectUpOne
)
if %_errorlevel%==13 goto RadioEnterPressed
goto SelectRadio
:SelectUpOne
Rem Remove trailing backslash if present
if "!directory:~-1!"=="\" set "directory=!directory:~0,-1!"
Rem Find the position of the last backslash
set "lastpos=0"
for /l %%a in (0,1,1000) do (
set /a "pos=lastpos+1"
set "char=!directory:~%%a,1!"
if "!char!"=="" set /a "lastpos-=1" & goto :S1break
if "!char!"=="\" set "lastpos=%%a"
)
:S1break
Rem Extract the path up to the last backslash
set /a lastpos+=1
set "upOne=!directory:~0,%lastpos%!"
set directory=!upOne!
goto :SelectRadio
:RadioEnterPressed
if exist "%directory%\%_SelectedFile%\*" (
set directory=%directory%\%_SelectedFile%
set selected=1
goto :SelectRadio
)
set Radio="%Directory%\%_SelectedFile%"
:LoadRadio
call %radio%
call :SetLC
call :setVC
Rem If path longer than 27 char, trim and append ...
set "len=0"
for /l %%A in (12,-1,0) do (
set /a "len|=1<<%%A"
for %%B in (!len!) do if "!SoftwarePath:~%%B,1!"=="" set /a "len&=~1<<%%A"
)
set /a "startPos=!len!-25"
if !len! gtr 27 (
set "DisplayPath=...!SoftwarePath:~%startPos%,26!"
) else (
set "DisplayPath=!SoftwarePath!"
)
:DisplayRadio
cls
call :Titlebar
echo [7m%vendor% %model%[0;90m Press E to Edit [0m
echo -------------------------------------------------
echo Connector: [95m%jack%[0m
echo TXD to Radio:-------Pin [96m%TXD%[0m
echo RXD From Radio:-----Pin [96m%RXD%[0m
if %RXD%==%TXD% echo [93mHALF-DUPLEX[0m
echo Ground Pin:---------Pin [96m%GND%[0m
echo Voltage: %VC%%Voltage%[0m
echo Compatible Cable: [96m%cable%[0m
set mismatch=N
if exist "Bin\Files\Cables\Owned\%Cable%.cmd" (
echo Owned?[32m Cable Owned[0m
) ELSE (
if exist "Bin\Files\Cables\%Cable%.cmd" (
echo Owned?[31m Cable Not Owned[0m
) ELSE (
echo Owned?[31m Cable Unknown[0m
)
)
echo [90m-------------------------------------------------[0m
echo Software: [96m%Software%[0m
echo Software Path: [36m%DisplayPath%[0m
if not "%SoftwarePath:"=%"=="None" (
if exist "%SoftwarePath:"=%" (
echo Installed: [32mSoftware Detected[0m
echo ---------^> [90mPress L to launch[0m
) ELSE (
echo Installed: [31mSoftware Not Detected[0m
)
)
echo License Required: %LC%%LicenseRequired%[0m
echo -------------------------------------------------
echo Notes: [93m%notes%[0m
echo -------------------------------------------------
echo|set /p="Pins twins: [90m "
for /f "tokens=* delims=" %%A in ('dir /b "Bin\Files\UIDS\%uid%\*.uid1"') do (
if not exist "Bin\Files\UID2S\%uid2%\%%~nA.uid2" (
set TwinName=%%~nA
echo|set /p="!TwinName:.= ! "
)
)
echo.
echo|set /p="[0mFull twins: [90m "
for /f "tokens=* delims=" %%A in ('dir /b "Bin\Files\UID2S\%uid2%\*.uid2"') do (
if not "%%~nA"=="%vendor%.%model%" (
set TwinName=%%~nA
echo|set /p="!TwinName:.= ! "
)
)
"Bin\kbd.exe"
if %errorlevel%==27 goto mainmenu
if %errorlevel%==59 goto mainmenu
if %errorlevel%==60 goto Updates
if %errorlevel%==61 start "" "%~0"
if %errorlevel%==62 goto COMS
if %errorlevel%==68 exit /b
if %errorlevel%==101 goto :PreConfigNewMenu
if %errorlevel%==108 (
pushd "%userprofile%"
start "" "%SoftwarePath%"
popd
goto :ReKBDNew
)
goto loadradio
goto DisplayRadio
:PreConfigNewMenu
Rem If path longer than 27 char, trim and append ...
set "len=0"
for /l %%A in (12,-1,0) do (
set /a "len|=1<<%%A"
for %%B in (!len!) do if "!SoftwarePath:~%%B,1!"=="" set /a "len&=~1<<%%A"
)
echo !len!
set /a "startPos=!len!-23"
if !len! gtr 27 (
set "DisplayPath=...!SoftwarePath:~%startPos%,24!"
) else (
set "DisplayPath=!SoftwarePath!"
)
goto confignewmenu
REM ==================================
REM START NEW RADIO SECTION
REM =================================
:AddRadio
set Selected=1
:SelectVendor
rem display a list of files in the Files\Vendors folder, allow the user to select one, and set the result to %vendor%
if "!Selected!"=="" set selected=1
cls
call :titlebar
echo [96;7mSelect Radio Vendor or Press N for new Vendor[0m
echo =================================================
set linecount=0
set item=0
set _skip=0
for /f "tokens=*" %%A in ('dir /b Bin\Files\Vendors') do (
set /a linecount+=1
set /a item+=1
set _echo=%%~A
if exist "%%~A\*.*" set _echo=}%%~A
set /a _tmpVar=!selected!-!item!
if !_tmpVar! LSS 35 (
if "!Selected!"=="!item!" (
echo [7m!_echo![0m *
set "_SelectedFile=%%~A"
set "_SelectedExtension=%%~xA"
) ELSE (
echo !_echo!
)
) ELSE (
set /a _skip+=1
)
set /a _tmpVar=!linecount!-!_skip!
if !_tmpVar!==%lines% (
echo | set /p "= . . ."
goto 1BreakLoop1
)
)
:1BreakLoop1
"Bin\Kbd.exe"
if %errorlevel%==110 goto newvendor
if %errorlevel%==59 goto mainmenu
if %errorlevel%==60 goto Updates
if %errorlevel%==61 start "" "%~0"
if %errorlevel%==62 goto COMS
if %errorlevel%==68 exit /b
set _errorlevel=%errorlevel%
rem if %_errorlevel%==59 goto options
if %_errorlevel%==80 (
if not !Selected! GEQ !linecount! (
set /a Selected+=1
)
)
if %_errorlevel%==72 (
if not !Selected! LEQ 1 (
set /a Selected-=1
)
)
if %_errorlevel%==13 goto SelectedVendor
goto selectvendor
:newvendor
echo Enter vendor name:
echo [90mX to cancel[0m
set /p Vendor=">"
if /i "%vendor%"=="X" goto :SelectVendor
echo.>"Bin\Files\Vendors\%Vendor:"=%"
goto NewModel
:SelectedVendor
set Vendor=%_SelectedFile:"=%
:NewModel
cls
echo Vendor: [7m%Vendor%[0m
echo ===========================
echo Enter new Model Number
set /p Model=">"
if exist "Bin\Files\Radios\%vendor%\%model%.cmd" (
echo This model already exists.
pause
goto mainmenu
)
set VendorURL=!vendor: =%%20!
set ModelURL=!Model: =%%20!
curl -s -H "Accept: application/vnd.github.v3.raw" -L https://api.github.com/repos/W1BTR/Programming-Assistant/contents/Bin/Files/Radios/!VendorURL!/!ModelURL!.cmd -o ModelCheck.Temp.cmd
find "https://docs.github.com/rest/repos/contents#get-repository-content" "ModelCheck.Temp.cmd" >nul 2>nul
if %errorlevel%==1 (
call ModelCheck.Temp.cmd
echo [7mA matching model name was found in the online
echo repository with the following details:[0m
echo Vendor: !vendor!
echo Model: !model!
echo Jack: !jack!
echo TXD: !txd!
echo RXD: !rxd!
echo GND: !gnd!
echo Voltage: !voltage!
echo Software: !software!
echo Cable: !cable!
echo Notes: !notes!
echo [92mDownload Model?[0m
choice
if %errorlevel%==2 (
del /f /q ModelCheck.Temp.cmd
goto CONFIGNEW
)
copy "ModelCheck.Temp.cmd" "Bin\Files\Radios\%vendor%\%model%.cmd"
del /f /q ModelCheck.Temp.cmd
)
goto CONFIGNEW
:CONFIGNEW
rem set some default variables
set jack=RJ45
set voltage=5V
set TXD=
set RXD=
set GND=
set Cable=
set Software=
set Notes=
set VoltageUnset=true
set LicenseRequired=Yes
set SoftwarePath=None
set selected=1
call :SetLC
call :SetVC
:Confignewmenu
call :setcursor
cls
call :titlebar
echo [92mEditing: %Vendor% %Model%[0m
echo [90m== Communication ================================[0m
echo %cur_1%1 Jack: [92m%jack%[0m
echo %cur_2%2 TXD (PC to Radio): [92m%TXD%[0m
echo %cur_3%3 RXD (Radio to PC): [92m%RXD%[0m
echo %cur_4%4 GND: [92m%GND%[0m
echo %cur_5%5 Voltage: %VC%%VOLTAGE%[0m
echo %cur_6%6 Cable Name: %cable%[0m
set mismatch=N
if exist "Bin\Files\Cables\%Cable%.cmd" (
call "Bin\Files\Cables\%Cable%.cmd"
if not "%TXD%"=="!CableTXD!" set mismatch=Y
if not "%RXD%"=="!CableRXD!" set mismatch=Y
if not "%GND%"=="!CableGND!" set mismatch=Y
if not "%Voltage%"=="!CableV!" set mismatch=Y
if "!mismatch!"=="Y" (
echo C Owned?[33m Cable mismatch[90m PRESS C
) ELSE (
if exist "Bin\Files\Cables\Owned\%Cable%.cmd" (
echo C Owned?[32m Cable Owned[0m
) ELSE (
echo C[31m Cable Unowned[90m Press C to mark as owned[0m
)
)
) ELSE (
echo C[31m Cable Unknown[90m Press C to add to library[0m
)
echo [90m== Software =====================================[0m
echo %cur_7%7 Software: [97m%Software%[0m
echo %cur_8%8 License Required: %LC%%LicenseRequired%[0m
echo %cur_9%9 Software Path: [90m%DisplayPath%[0m
if not "%SoftwarePath:"=%"=="None" (
if exist "%SoftwarePath:"=%" (
echo L Detected?[32m Software Detected[0m
) ELSE (
echo L Detected?[31m Software Not Detected[0m
)
) ELSE (
echo [90mEnter software path to detect install[0m
)
echo [90m== Notes ========================================[0m
echo %cur_0%0 Notes: [7m%notes%[0m
echo -------------------------------------------------
echo Press [97mS[0m to save
echo Press [97mI[0m to import from twin radio
echo Press [97mX[0m to close
if not "%SoftwarePath:"=%"=="None" (
if exist "%SoftwarePath:"=%" echo Press [97mL[0m to Launch %Software%
)
echo -------------------------------------------------
REM TODO
rem navigate creation
rem create uniqueID to find programming cable twins
rem save to file
rem twin importing
:ReKBDNew
"Bin\Kbd.exe"
if %errorlevel%==80 (
if not !Selected! GEQ 10 (
set /a Selected+=1
)
)
if %errorlevel%==72 (
if not !Selected! LEQ 1 (
set /a Selected-=1
)
)
if %errorlevel%==108 (
pushd "%userprofile%"
start "" "%SoftwarePath%"
popd
goto :ReKBDNew
)
cls
if %errorlevel%==49 (
call :SetJack
goto :Confignewmenu
)
if %errorlevel%==50 (
call :SetTXD
goto :Confignewmenu
)
if %errorlevel%==51 (
call :SetRXD
goto :Confignewmenu
)
if %errorlevel%==52 (
call :SetGND
goto :Confignewmenu
)
if %errorlevel%==53 (
call :SetVLT
call :SetVC
goto :Confignewmenu
)
if %errorlevel%==54 (
call :SetCable
goto :Confignewmenu
)
if %errorlevel%==55 (
call :SetSoftware
goto :Confignewmenu
)
if %errorlevel%==56 (
call :SetLicense
call :SetLC
goto :Confignewmenu
)
if %errorlevel%==57 (
call :SetSPath
goto :Confignewmenu
)
if %errorlevel%==48 (
call :SetNote
goto :Confignewmenu
)
if %errorlevel%==59 goto mainmenu
if %errorlevel%==60 goto Updates
if %errorlevel%==61 start "" "%~0"
if %errorlevel%==62 goto COMS
if %errorlevel%==68 exit /b
if %errorlevel%==105 goto importRadio
if %errorlevel%==13 goto SelNewMenu
if %errorlevel%==115 goto SaveRadio
if %errorlevel%==120 goto mainmenu
if %errorlevel%==99 (
call :SaveCable
goto :Confignewmenu
)
goto Confignewmenu
:importRadio
:SaveCable
if %mismatch%==N (
if exist "Bin\Files\Cables\%cable%.cmd" (
echo [92mCable exists but is marked as unowned.[0m
goto DoYouOwn
) ELSE (
echo [92mAdding new cable to library[0m
)
) ELSE (
echo [91mCable Mismatch[0m
)
if not exist "Bin\Files\Cables\Owned\" md "Bin\Files\Cables\Owned\"
if %mismatch%==Y call :updatecable
if %mismatch%==Y exit /b
echo Ensure the pins are set up properly
echo [97mbefore[0m saving the cable.
echo.
echo TXD to Radio: %TXD%
echo RXD from Radio: %RXD%
echo GND for both: %GND%
echo Data Voltage: %voltage%
echo.
echo Save?
choice
if %errorlevel%==2 exit /b
(echo @echo off)>"Bin\Files\Cables\%Cable%.cmd"
(Echo set CableTXD=%TXD%)>>"Bin\Files\Cables\%Cable%.cmd"
(Echo set CableRXD=%RXD%)>>"Bin\Files\Cables\%Cable%.cmd"
(Echo set CableGND=%GND%)>>"Bin\Files\Cables\%Cable%.cmd"
(Echo set CableV=%voltage%)>>"Bin\Files\Cables\%Cable%.cmd"
echo [92mCable Saved.[0m
:DoYouOwn
echo Do you own this cable?
choice
if %errorlevel%==1 (
(Echo.)>>"Bin\Files\Cables\Owned\%Cable%.cmd"
echo [92mCable added to owned Library.[0m
) ELSE (
if exist "Bin\Files\Cables\Owned\%Cable%.cmd" (
del /f /q "Bin\Files\Cables\Owned\%Cable%.cmd"
echo [92mCable removed from owned Library.[0m
)
)
pause
exit /b
:updatecable
rem color code
if not "%TXD%"=="%CableTXD%" (
set pTXD=[91m
) ELSE (
set pTXD=
)
if not "%RXD%"=="%CableRXD%" (
set pRXD=[91m
) ELSE (
set pRXD=
)
if not "%GND%"=="%CableGND%" (
set pGND=[91m
) ELSE (
set pGND=
)
if not "%voltage%"=="%CableV%" (
set pV=[91m
) ELSE (
set pV=
)
echo The current Pin Layout does not
echo match the pins saved for %cable%.
echo [93;7mCurrent Settings:[0m
echo TXD to Radio: !pTXD!%TXD%[0m
echo RXD from Radio: !pRXD!%RXD%[0m
echo GND for both: !pGND!%GND%[0m
echo Data Voltage: !pV!%voltage%[0m
echo [96;7m%cable% Saved Pins:[0m
echo TXD to Radio: !pTXD!%CableTXD%[0m
echo RXD from Radio: !pRXD!%CableRXD%[0m
echo GND for both: !pGND!%CableGND%[0m
echo Data Voltage: !pV!%CableV%[0m
echo.
echo 1] Overwrite saved cable
echo 2] Pull from saved cable
echo 3] Change cable name
echo X] Go back
choice /c 1234x
if %errorlevel%==1 (
(echo @echo off)>"Bin\Files\Cables\%Cable%.cmd"
(Echo set CableTXD=%TXD%)>>"Bin\Files\Cables\%Cable%.cmd"
(Echo set CableRXD=%RXD%)>>"Bin\Files\Cables\%Cable%.cmd"
(Echo set CableGND=%GND%)>>"Bin\Files\Cables\%Cable%.cmd"
(Echo set CableV=%voltage%)>>"Bin\Files\Cables\%Cable%.cmd"
echo [92mCable Saved.[0m
pause
exit /b
)
if %errorlevel%==2 (
set TXD=%CableTXD%
set RXD=%CAbleRXD%
set GND=%CableGND%
set Voltage=%CableV%
echo [96mPulled Settings.[0m
pause
exit /b
)
if %errorlevel%==3 (
call :SetCable
exit /b
)
exit /b
:SetVC
set VC=[91m
rem set color of voltage text depending on value, and append V if needed
if "!Voltage!"=="5V" set VC=[92m
if "!Voltage!"=="3.3V" set VC=[96m
if "!Voltage!"=="1.8V" set VC=[93m
if "!Voltage!"=="5" set VC=[92m& set Voltage=5V
if "!Voltage!"=="3.3" set VC=[96m& set Voltage=3.3V
if "!Voltage!"=="1.8" set VC=[93m& set Voltage=1.8V
exit /b
:SetLC
rem set color of License Required text
if "!LicenseRequired!"=="Yes" set LC=[91m
if "!LicenseRequired!"=="No" set LC=[92m
exit /b
:SetCable
echo Enter name of a cable (i.e. Kenwood KPG-46X):
set /p cable=">"
if exist "Bin\Files\Cables\%Cable%.cmd" (
call "Bin\Files\Cables\%Cable%.cmd"
if "%TXD%"=="" set TXD=!CableTXD!
if "%RXD%"=="" set RXD=!CableRXD!
if "%GND%"=="" set GND=!CAbleGND!
if "%VoltageUnset%"=="True" set voltage=!CableV!
)
exit /b
:SetNote
echo Enter a new note:
set /p notes=">"
exit /b
:SelNewMenu
rem enter was pressed, figure out which menu to go to
if %selected%==1 (
call :SetJack
goto :Confignewmenu
)
if %selected%==2 (
call :SetTXD
goto :Confignewmenu
)
if %selected%==3 (
call :SetRXD
goto :Confignewmenu
)
if %selected%==4 (
call :SetGND
goto :Confignewmenu
)
if %selected%==5 (
call :SetVLT
call :SetVC
goto :Confignewmenu
)
if %selected%==6 (
call :SetCable
goto :Confignewmenu
)
if %selected%==7 (
call :SetSoftware
goto :Confignewmenu
)
if %selected%==8 (
call :SetLicense
call :SetLC
goto :Confignewmenu
)
if %selected%==9 (
call :SetSPath