April 27, 2024, 11:28:35 AM

News:

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


Serial port communication

Started by Egil, March 11, 2011, 11:11:52 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Egil

March 11, 2011, 11:11:52 AM Last Edit: March 13, 2011, 09:12:52 AM by Egil
Here is the EXE version of a serial port program I have made with CB. The program was made to figure out how the commands and other info are handled in a remote control circuit for one of my radio ham transceivers. I'm also using it for packet radio communications with an old KPC-4 radio modem as shown in the picture. I don't post the source, as I reckon that code will have to be modified when the modified CB serial component is posted. The help file is only in norwegian, so it is not included, but the menues should be easy to understand.
Thanks to all that have guided me understanding how to use the IWB products!

Have fun,
Egil

EDIT: There was a typo in the Baudrate menu. It showed 57500 and should have been 57600. The speed used for comms was correct though... Corrected file uploaded.
Support Amateur Radio  -  Have a ham  for dinner!

tbohon

And guess who is in the process of setting up a packet station at home ... ? :)

Thanks Egil - will try and 'play' this weekend.

73,

Tom / KE7EJJ
"If you lead your life the right way, the karma will take care of itself ... the dreams will come to you."  -- Randy Pausch, PhD (1961-2008)

Egil

Support Amateur Radio  -  Have a ham  for dinner!

Techno

Egil,

I'm very interested in your source code.
Can you post here the source code?
Best regards
Stephane

Egil

Stephane,

Here is the code, but it is totally useless to you, unless you have the Serial Library Component offered by Paul Turley just before he sold Ionic Wind to Larry Sykes. That library has been modified by Larry, as he found bugs in it. I don't know when he will be able to offer it again, but when he does so, the code has to be rewritten as I stated in my first post over.

I have no comports on my computer, and use USB_to_Serialport cables only. As long as these converters has been issued comport numbers less than 9, the code will report them as active. Otherwise they are greyed out in the menu. The program lacks one very important feature, which you most probably will need for more serious work: error trapping. But I'll leave that up to you.


Have fun!
Egil

' CB-term.cba  (v007)
' By: LA2PJ - Egil Ingebrigtsen
'
' ########## NOTE ###############################################################
' This code needs the CB Serial Component to work, and must
' probably be modified when the modified Serial Component is posted.
' ###############################################################################
'

' API functions
DECLARE "user32.dll",GetSysColor(nIndex:INT),INT
DECLARE "user32.dll",GetDlgItem(hDlg:INT, nIDDlgItem:INT),INT
DECLARE "user32.dll",GetDlgCtrlID(hwnd:INT),INT

def TRUE,FALSE:int
TRUE=1
FALSE=0

CONST COM1=1
CONST COM2=2
CONST COM3=3
CONST COM4=4
CONST COM5=5
CONST COM6=6
CONST COM7=7
CONST COM8=8

' Initiate the Serial component Library:
SerialStartup



CONST WM_SETCURSOR = 0x20

DEF answer,cid,chng,sh:INT
DEF myicon:int

DEF d1:DIALOG
DEF  win:WINDOW
DEF Tx$[512]:istring
DEF textpar,ports,cleft,ctop,cwidth,cheight,run,crxl,crxt,crxw,crxb,ctxl,ctxt,ctxw,ctxb:int

DECLARE SaveSetup(sFilePath:string)
DECLARE LoadSetup(sFilePath:string)
DECLARE RE_Append(win:WINDOW,id:int,text:string)
DECLARE FindComPorts(port:int)
DECLARE SetComPort()
DECLARE GetRxD()
DECLARE PutTxD()
DECLARE Resize()
DECLARE CleanUp()
DECLARE aboutbox()

TYPE COMPARAMS
def comport:int
def baud:int
def bits:int
def parity:int
def stopbits:int
def oldport:int
def localecho:int
ENDTYPE
DEF pb:COMPARAMS

CONST ON=1
CONST OFF=0

def cfgfile,ctext,CR,CRLF:string
def Rx$[4096]:istring
CR =  chr$(0x0d)
CRLF= chr$(0xd)+chr$(0xa)
cfgfile = "CB-term.cfg"

def tpar[4]:string
tpar[0] = "","N","O","E"


WINDOW win,0,0,640,340,@minbox|@size,0," CB-term",main
DIALOG d1,0,0,295,230,@CAPTION|@SYSMENU,win,"  About  CB-term",aboutbox

CENTERWINDOW win
SETWINDOWCOLOR win, RGB(222,222,222)

' MENUES:

' File menu
m0$="T,File,0,0"
m1$= "I,Save setup,0,1"
m2$= "I,Exit,0,2"

' Setup menu
m3$="T,Setup,0,0"
m4$= "S,Select Port,0,0"
m5$= "I,Com1,1,5"
m6$= "I,Com2,1,6"
m7$= "I,Com3,1,7"
m8$= "I,Com4,1,8"
m9$= "I,Com5,1,9"
m10$= "I,Com6,1,10"
m11$= "I,Com7,1,11"
m12$= "I,Com8,1,12"

m13$= "^S,Select baudrate,0,0"
m14$= "I,   110,0,14"
m15$= "I,   300,0,15"
m16$= "I,   600,0,16"
m17$= "I,  1200,0,17"
m18$= "I,  2400,0,18"
m19$= "I,  4800,0,19"
m20$= "I,  9600,0,20"
m21$= "I, 14400,0,21"
m22$= "I, 19200,0,22"
m23$= "I, 28800,0,23"
m24$= "I, 38400,0,24"
m25$= "I, 57600,0,25"
m26$= "I,115200,0,26"

m27$= "^S,Select Bits,0,0"
m28$= "I,7,0,28"
m29$= "I,8,0,29"

m30$= "^S,Select Parity,0,0"
m31$= "I,No,0,31"
m32$= "I,Odd,0,32"
m33$= "I,Even,0,33"

m34$= "^S,Select Stopbits,0,0"
m35$= "I,1,0,35"
m36$= "I,2,0,36"

m37$= "^S,Local Echo,0,0"
m38$= "I,On,0,38"
m39$= "I,Off,0,39"

' Help menu
m40$="T,Help,0,0"
m41$= "I,About,0,41"
m42$= "I,User manual,0,42"

MENU win,m0$,m1$,m2$,m3$,m4$,m5$,m6$,m7$,m8$,m9$,m10$,m11$,m12$,m13$,m14$,m15$,m16$,m17$,m18$,m19$,m20$,m21$,m22$,m23$,m24$,m25$,m26$,m27$,m28$,m29$,m30$,m31$,m32$,m33$,m34$,m35$,m36$,m37$,m38$,m39$,m40$,m41$,m42$


' TX and RX window sizes
GETCLIENTSIZE win,cleft,ctop,cwidth,cheight

' rx window
crxl = cleft
crxt = ctop
crxw = cwidth
crxb = cheight-(85)

' tx window
ctxl = cleft
ctxt = ctop+(cheight-80)
ctxw = cwidth
ctxb = cheight

' TX-window
CONTROL win,"RE,,ctxl,ctxt,ctxw,ctxw,@CTEDITMULTI|@CTEDITRETURN,1"
SETCONTROLCOLOR win, 1, RGB(0,0,0), RGB(255,255,255)
SETFOCUS win, 1

' RX-window
CONTROL win,"RE,,crxl,crxt,crxw,crxb,@CTEDITMULTI|@VSCROLL,2"
SETCONTROLCOLOR win, 1, RGB(0,0,0), RGB(255,255,255)

' About Box static texts
CONTROL d1,"T,This program was written by Egil - LA2PJ as a learning.,14,10,290,14,0,1"
CONTROL d1,"T,exercise. My intention was to make a program using,14,25,290,14,0,2"
CONTROL d1,"T,most common components found in the majority of ,14,40,290,14,0,3"
CONTROL d1,"T,Windows programs.,14,55,290,14,0,4"
CONTROL d1,"T,This program was developed with:,0,90,290,14,0x50000101,5"
CONTROL d1,"T,Creative Basic Version 1.153,0,105,290,14,0x50000101,6"
CONTROL d1,"T,(A product of Ionic Wind Software),0,120,290,14,0x50000101,7"
CONTROL d1,"T,Thanks to all the good helpers at the,0,150,290,14,0x50000101,8"
CONTROL d1,"T,Ionic Wind Software User Forums!,0,165,290,14,0x50000101,9"
CONTROL d1,"B,OK,120,200,60,20,0x50010001,10"

' Find available comports (menu ID's 5 to 12)
for ports = 1 to 8
if FindComPorts(ports)
ENABLEMENUITEM win,ports+4,1
endif
next ports

' Load comport parameters or use defaults
LoadSetup(cfgfile)

STARTTIMER win,60,1
run = 1

WAITUNTIL run = 0
stoptimer win,1

CLOSEWINDOW win
END


'==================================================================================
SUB main

SELECT @CLASS

case @IDCLOSEWINDOW
CleanUp()

  case @IDMENUPICK
      SELECT @MENUNUM
case 1
SaveSetup(cfgfile)
        case 2
CleanUp()

' Select Comport
case 5
pb.oldport=pb.comport : pb.comport=COM1 : SetComPort()
case 6
pb.oldport=pb.comport : pb.comport=COM2 : SetComPort()
case 7
pb.oldport=pb.comport : pb.comport=COM3 : SetComPort()
case 8
pb.oldport=pb.comport : pb.comport=COM4 : SetComPort()
case 9
pb.oldport=pb.comport : pb.comport=COM5 : SetComPort()
case 10
pb.oldport=pb.comport : pb.comport=COM6 : SetComPort()
case 11
pb.oldport=pb.comport : pb.comport=COM7 : SetComPort()
case 12
pb.oldport=pb.comport : pb.comport=COM8 : SetComPort()

' Select baudrate
case 14
pb.baud=110 : SetComPort()
case 15
pb.baud=300 : SetComPort()
case 16
pb.baud=600 : SetComPort()
case 17
pb.baud=1200 : SetComPort()
case 18
pb.baud=2400 : SetComPort()
case 19
pb.baud=4800 : SetComPort()
case 20
pb.baud=9600 : SetComPort()
case 21
pb.baud=14400 : SetComPort()
case 22
pb.baud=19200 : SetComPort()
case 23
pb.baud=28800 : SetComPort()
case 24
pb.baud=38400 : SetComPort()
case 25
pb.baud=57600 : SetComPort()
case 26
pb.baud=115200 : SetComPort()

' Select number of bits
case 28
pb.bits=7 : SetComPort()
case 29
pb.bits=8 : SetComPort()

' Select parity
case 31 :' Parity = NO
pb.parity=0 : SetComPort()
case 32 :' Parity = ODD
pb.parity=1 : SetComPort()
case 33 :' Parity = EVEN
pb.parity=2 : SetComPort()

' Select stopbits
case 35 :' 1 Stop bit
pb.stopbits=1 : SetComPort()
case 36 :' 2 Stop bits
pb.stopbits=2 : SetComPort()

' Set local echo ON/OFF
case 38
pb.localecho=ON : SetComPort()
case 39
pb.localecho=OFF : SetComPort()

' Help menu
case 41 :' About Box
DOMODAL d1
case 42 :' Open User Manual
SYSTEM "tnc.chm"

      ENDSELECT

case @idtimer
Rx$=GetRxD() :' Get received data
RE_Append(win,2,Rx$) :' Print received data

case @IDSIZE :' resize window and editboxes
Resize()

ENDSELECT

if GETKEYSTATE(13) :' ENTER is pressed
do: until getkeystate(13) = 0  
PutTxD()
endif

if GETKEYSTATE(27) :' ESC is pressed - program terminates
CleanUp()
endif

RETURN
'==================================================================================

'zczc
'ÂÃ,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨
' Reads whatever is in the comport buffer
'
SUB GetRxD()
def ret[1024]:istring
def pRet:pointer
def cnt,buf:int
pRet = ret
if GetComBytesWaiting(pb.comport)
buf = GetComBytesWaiting(pb.comport)
cnt = ReadComPort(pb.comport,pRet,buf)
ret[cnt] = ""
else
ret=""
endif
RETURN ret
'+++++

'zczc
'ÂÃ,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨
' Send keyboard input
'
SUB PutTxD()
def Tx$:string
def j:int
j=1
Tx$ = GETCONTROLTEXT(win, 1) :'+CR :' Retrieve text from input control
if Tx$="" then Tx$=CRLF
do
SendComportString(pb.comport,mid$(Tx$,j,1),1) :' Send all text in input control
j=j+1
until mid$(Tx$,j,1) = chr$(10)
if pb.localecho=TRUE THEN RE_Append(win,2,Tx$) :' Local echo=ON
SETCONTROLTEXT win, 1, "" :' Clear input control
RETURN
'+++++

'zczc
'ÂÃ,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨
' Append text to RX window and scroll if necessary
'
SUB RE_Append(win:WINDOW,id:int,text:string)
def re$[65535]:istring
def count:int
def lines:int
re$ = GETCONTROLTEXT (win, 2)
re$ = re$ + text
SETCONTROLTEXT win, 2, re$
count = CONTROLCMD ( win, 2, @RTGETLINECOUNT)
lines = CONTROLCMD ( win, 2, @RTGETFIRSTLINE)
CONTROLCMD win, 2, @RTSCROLL, count-lines-((cheight-85)/16)+.5, 0
RETURN
'+++++

'zczc
'ÂÃ,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨
' Resize window and edit controls
'
SUB Resize()
if CONTROLEXISTS(win,1)
GETCLIENTSIZE win,cleft,ctop,cwidth,cheight
' rx window
crxl = cleft
crxt = ctop
crxw = cwidth
crxb = cheight-(85)
' tx window
ctxl = cleft
ctxt = ctop+(cheight-80)
ctxw = cwidth
ctxb = cheight
setsize win,ctxl,ctxt,ctxw,ctxw,1
setsize win,crxl,crxt,crxw,crxb,2
RE_Append(win,2,"") :' FORCE SCROLLING ON RESIZE!!!!!
endif
RETURN
'+++++

'zczc
'ÂÃ,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨
' Find available comports  - returns TRUE (port found) or FALSE
'
SUB FindComPorts(port:int)
if OpenComPort(port,115200)
ret = TRUE
else
ret = FALSE
endif
Closecomport(port)
RETURN ret
'+++++

'zczc
'ÂÃ,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨
' Set ComPort
'
SUB SetComPort()
if pb.localecho=ON then echo=" - Local Echo: ON"
if pb.localecho=OFF then echo=" - Local Echo: OFF"
CloseComport(pb.comport)
OpenComPort(pb.comport,pb.baud)
SetComReadTimeout(pb.comport,-1)
SetComProperties(pb.comport,pb.bits,pb.parity,pb.stopbits)
textpar=(pb.parity)+1
ctext = "  CB-term   -   Port status = COM"+right$(str$(pb.comport),1)+":"+str$(pb.baud)+","+right$(str$(pb.bits),1)+ ","+tpar[textpar]+","+ right$(str$(pb.stopbits),1) + echo
SETCAPTION win,ctext
RETURN
'+++++

'zczc
'ÂÃ,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨
'  Load setup from file - or use default settings
'
SUB LoadSetup(sFilePath:string)
def iFile:FILE
if OpenFile(iFile, sFilePath, "R") = 0
read(iFile, pb.comport)
read(iFile, pb.baud)
read(iFile, pb.bits)
read(iFile, pb.comport)
read(iFile, pb.parity)
read(iFile, pb.stopbits)
read(iFile, pb.localecho)
CloseFile iFile
SetComPort()
else
pb.comport=COM1
pb.baud=9600
pb.bits=8
pb.parity=0
pb.stopbits=1
pb.oldport=pb.comport
pb.localecho=TRUE
SetComPort()
RE_Append(win,2,CRLF+"Configfile NOT found - using default values")
endif
RETURN
'+++++

'zczc
'ÂÃ,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨
'  Save setup to file
'
SUB SaveSetup(sFilePath:string)
def iFile:FILE
if OpenFile(iFile, sFilePath, "W") = 0
write(iFile, pb.comport)
write(iFile, pb.baud)
write(iFile, pb.bits)
write(iFile, pb.comport)
write(iFile, pb.parity)
write(iFile, pb.stopbits)
write(iFile, pb.localecho)
CloseFile iFile
Else
RE_Append(win,2,"Unable to save Config file")
EndIf
RETURN
'+++++

'zczc
'ÂÃ,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨
'  Clean Up routine so program can end properly
'
SUB CleanUp()
SaveSetup(cfgfile)
Closecomport(pb.comport)
run=0
RETURN
'+++++

'zczc
'ÂÃ,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨Ã‚Ã,¨
'  About Box  - using a dialog: d1
'
SUB aboutbox()
SELECT @CLASS
case @IDINITDIALOG
CENTERWINDOW d1
SetControlColor d1,6,0xFF0000,Getsyscolor(15)
SETCONTROLCOLOR d1,10,RGB(0,0,0),RGB(192,192,192)

cid=0:chng=0
sh = GetDlgItem(d1.hwnd,6)

case @IDCONTROL
select @CONTROLID
case 6
System "http://www.ionicwind.com/cbasic.html"
           SendMessage (d1,WM_SetCursor,0,sh)
case 10
closedialog d1,@IDOK
endselect

' Change text color when cursor over text
case WM_SetCursor
cid = GetDlgCtrlID(@Code) - 2024
if (cid = 6) & (chng = 0)
SetFont d1,"",8,400,@SFUnderLine,6
SetControlColor d1,6,0x00000FF,Getsyscolor(15)
chng = 1
else
if (cid <> 6)& (chng = 1)
SetFont d1,"",8,400,0,6  
SetControlColor d1,6,0xFF0000,Getsyscolor(15)
chng = 0
endIf
endif

ENDSELECT
RETURN
'+++++

Support Amateur Radio  -  Have a ham  for dinner!