Hello Don and all,
As promised I post the documentation for the "Simple ON/OFF RS-232" solution. The solution is usable for a RS-232 port, or via a RS-232 to USB cable via a USB port.
The plugin gtRS232free7.nbp is needed to use this sample.
A simple box is used with a few components:
Schematics:
RS-232 Connect pin-out (see also schematics):
Below my code. I use a loop because of my application but I think the code is simple and can be changed for your own needs...
Code: Select all
NBW Publication Source File
(C)2014 NeoSoft Corp.
Title=Untitled NeoBook Publication
Language=US
NeoBookVer=5,80
ScreenColors=16777216
ScreenWidth=800
ScreenHeight=600
BkndColor=0
ScreenAutoSize=Yes
LinkColor=16711680
WindowStyle=0
WindowOrder=0
WindowPos=0
WindowProps=31
BiDiMode=0
UseUpdateTimer=Yes
ReturnTime=60
ShapeTransColor=536870912
SplashProps=3
CompiledName=G:\000 Application Development\FisRS232\FisRS232.exe
CompileType=0
MediaType=0
FilesIncluded=1
FontsIncluded=2
FontsToCompile=|
CopyExternalFiles=No
SetupMedia=3
SetupInstDir=C:\MyProgram
SetupTitle=Setup
SetupColors=16711680|0|65535
Variables=[cport]¶[Loop]¶[Message]¶[rx]¶
VersionMajor=1
VersionMinor=0
VersionRelease=0
VersionBuild=0
ReqExLevel=1
CustomFontName=Arial
CustomFontSize=9
CustomFontStyle=0
CustomCharset=1
CacheSize=30
ExtractOp=132
L_OK=OK
L_CANCEL=Cancel
L_YES=Yes
L_NO=No
L_CLOSE=Close
L_ERRORTITLE=Error
L_FINDTITLE=Find
L_FINDPROMPT=Find &What
L_FINDFIRST=&Find First
L_FINDNEXT=Find &Next
L_FINDERROR=Search text not found.
L_PWORDTITLE=Password required
L_PWORDMSG=Before continuing, you must first|enter the correct password.
L_PWORDPROMPT=&Password:
L_PWORDERROR=That's not the right password!
L_MEDIAERROR=In order to play this type of file you must install|the appropriate multimedia hardware and/or|software.
L_INTERNETERROR=Unable to locate Internet Browser software.
L_ABORTFUNCTION=Do you want to cancel this function?
L_EXTRACTERROR=This file could not be extracted and cannot be played.
L_INSTDIRPROMPT=Please enter the drive and directory where you would like this program to be installed. To accept the default drive and directory, simply press Enter.
L_INSTFOLDERPROMPT=Do you wish to create a program folder?
L_INSTRUNPROMPT=Do you want to run
L_INSTDISKPROMPT=Please insert disk #
L_INSTDISKERROR=That's not the correct disk, try again.
L_INSTGENERROR=The installation has terminated.
L_INSTEXITPROMPT=Do you really want to cancel the installation?
L_INSTWINTITLE=Setup
L_INSTPROGTITLE=Extracting Files...
L_SENDEMAIL=Sending Mail...
L_MAILSERVER=Please enter the name of your outgoing email server:
L_COPY=Copy to Clipboard
L_SELECTALL=Select All
L_DONWLOADFILE=Downloading: %s
L_PLEASEWAIT=Please wait...
TrayMenuBegin
MenuName=TrayOpen
MenuText=Open
MenuState=3
MenuKey=0
MenuAction=SetVar "[WindowState]" "Normal"
MenuName=TrayExit
MenuText=Exit
MenuState=3
MenuKey=0
MenuAction=Exit "" ""
MenuEnd
MasterPage
NewPage=New Page
PageStyle=0
PageColor=16777215
PageGradient1=16711680
PageGradient2=255
PageGradientDir=1
WallpaperStyle=0
ObjectType=8
Name=Text1
X=0
Y=45
W=800
H=515
Anchor=5
Font=Arial
FontSize=150
FontStyle=0
FontCharset=1
TextColor=0
Text={\rtf1\ansi\deff0\deftab254{\fonttbl{\f0\fnil\fcharset1 Arial;}}{\pard{\qc\li0\fi0\ri0\sb0\sl\sa0 \plain\f0\fs300\cf0 [rx]}}}
HMargin=0
VMargin=150
LineColor=0
LineWidth=1
LineStyle=0
FillColor=12632256
FillPattern=0
TabOrder=1
ObjectType=21
Name=Container1
X=0
Y=0
W=800
H=45
Anchor=1
LineColor=0
LineWidth=1
LineStyle=0
FillColor=10053171
FillPattern=0
TabOrder=3
HMargin=0
VMargin=0
ContainerBegin
ObjectType=3
Name=PushButton1
X=1
Y=1
W=100
H=43
Anchor=3
Text=Start
Align=2
ImageStyle=0
ObjAction=SetVar "[cport]" "4"¶SetVar "[rx]" "0"¶SetVar "[Message]" "Waiting...."¶SetVar "[ExitLoopRequested]" "False"¶Loop "1" "1000" "[Loop]"¶ gtCommOpenStd "4,1200"¶ gtCommRxCount "[cport],rx"¶ gtCommRxS "[cport],RXS,1"¶ gtCommRxByte "[cport],RXS,1"¶ If "[rx]" ">" "0"¶ SetVar "[Message]" "Done...."¶ AlertBox "Pressed" "The button is pressed, Test OK"¶ gtCommClose "[cport]"¶ ExitLoop¶ EndIf¶ If "[ExitLoopRequested]" "=" "True"¶ ExitLoop¶ EndIf¶EndLoop¶SetVar "[Message]" "Press startkey to test"¶SetVar "[rx]" "0"
LineColor=0
LineWidth=1
LineStyle=0
FillColor=12632256
FillPattern=0
Font=Arial
FontSize=10
FontStyle=0
FontCharset=1
TextColor=0
TabOrder=0
ObjectType=8
Name=Text2
X=101
Y=1
W=598
H=43
Anchor=5
Font=Arial
FontSize=24
FontStyle=0
FontCharset=1
TextColor=16777215
Text={\rtf1\ansi\deff0\deftab254{\fonttbl{\f0\fnil\fcharset1 Arial;}}{\pard{\qc\li0\fi0\ri0\sb0\sl\sa0 \plain\f0\fs48\cf0 [Message]}}¶}
HMargin=0
VMargin=0
LineColor=0
LineWidth=1
LineStyle=0
FillColor=12632256
FillPattern=1
TabOrder=1
ObjectType=3
Name=PushButton3
X=699
Y=1
W=100
H=43
Anchor=4
Text=Cancel
Align=2
ImageStyle=0
ObjAction=SetVar "[ExitLoopRequested]" "True"¶SetVar "[Message]" "Press startkey to test"
LineColor=0
LineWidth=1
LineStyle=0
FillColor=12632256
FillPattern=0
Font=Arial
FontSize=10
FontStyle=0
FontCharset=1
TextColor=0
TabOrder=2
ContainerEnd
ObjectType=21
Name=Container2
X=0
Y=560
W=800
H=40
Anchor=2
LineColor=0
LineWidth=1
LineStyle=0
FillColor=12632256
FillPattern=0
TabOrder=2
HMargin=0
VMargin=0
ContainerBegin
ObjectType=8
Name=Text3
X=25
Y=10
W=155
H=25
Anchor=0
Font=Arial
FontSize=150
FontStyle=0
FontCharset=1
TextColor=0
Text={\rtf1\ansi\deff0\deftab254{\fonttbl{\f0\fnil\fcharset1 Arial;}}{\pard{\ql\li0\fi0\ri0\sb0\sl\sa0 \plain\f0\fs24\cf0 [RXS]}}}
HMargin=0
VMargin=150
LineColor=0
LineWidth=1
LineStyle=0
FillColor=12632256
FillPattern=0
TabOrder=0
ContainerEnd
Button press in action:
I hope the instructions are understandable, otherwise let me know....
Regards,
Eric