April 19, 2024, 05:21:23 AM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


Tool for setting up Serial Ports.

Started by Egil, October 19, 2014, 05:16:12 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Egil

This is the source code the FindPorts.exe that is included in the IW Serial Port Library. The program have saved me a lot of time since the first version was made some years ago.
I also attach a zip archive containing the program, plus the help file that did not make it into the library.

Good luck!


'
' Findports.iwb  -  Using the IWB Comms Library v2.0
'
AutoDefine "Off"

def win:window 
def run,wstyle:int 
def csx,csy,csw,csh:int
wstyle = @MINBOX|@SIZE|@TOPMOST

OpenWindow win,0,0,320,310,wstyle,0,"  LA2PJ's Comport Finder",&messages 
SETWINDOWCOLOR(win,RGB(236,218,110))

BEGINMENU win
MENUTITLE "Menu"
menuitem "Open Device Manager",0,21
SEPARATOR
menuitem "About",0,90
menuitem "Help",0,91
SEPARATOR
menuitem "Exit Program",0,99
ENDMENU

GETCLIENTSIZE win,csx,csy,csw,csh

move win, csx+6,csy+12
BACKPEN win,RGB(236,218,110)
PRINT win, "ComPorts found:"

CONTROL win,@LISTBOX,"",csx+5,csy+30,120,csh-35,@VSCROLL,101
CONTROL win,@BUTTON,"New Search",csx+160,csy+110,100,25,0,102
FindComPorts()

run = 1 
WAITUNTIL run = 0 
CLOSEWINDOW win 
END 

SUB messages(),int
setfocus win, 102
SELECT @class
CASE @idcreate 
centerwindow win

CASE @idclosewindow 
run = 0 

CASE @IDMENUPICK
select @MENUNUM
case 21 ' Open Device Manager
system "devmgmt.msc"

case 90 ' About
MESSAGEBOX(win,"       This is FREEWARE from LA2PJ"+chr$(13)+chr$(13)+_
"  The program finds installed ComPorts"+chr$(13)+_
"                Use at your own risk!",_
"About Comports",@MB_OK|@MB_ICONINFORMATION)

case 91 ' Help
system "FindPorts.chm"

case 99 ' Exit
run=0

endselect

CASE @idcontrol 
select @controlID

case 1 
run = 0 

case 102
FindComPorts()
endselect

ENDSELECT 
RETURN  0
EndSub

'
'----------------------------------------------------------------------------------------
' 1. Deletes all listbox contents.
' 2. Try to open all the 256 possible Windows ComPorts at 115200 baud.
' 3. Any port that opens, is added to the listbox.
'
SUB FindComPorts()
dim pp,i,j:int
dim txt$:string

j = GETSTRINGCOUNT (win,101)
for i=j to 0 STEP -1
DELETESTRING win,101,i
next i

for pp = 1 to 256
if IWOpenPort(pp,115200)
txt$="COM"+right$(str$(pp),len(str$(pp))-1)
ADDSTRING win,101,txt$
IWClosePort(pp)
endif
next pp

RETURN
ENDSUB




Support Amateur Radio  -  Have a ham  for dinner!

LarryMc

LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library