'------------------------------------------------------------------------------- ' WCSPrismV30.BAS, for QB64 compiler for Windows ' WCS BetaBrite Prism Control Sample v3.0 (serial) ' Copyright 2013, All Rights Reserved ' Provided courtesy of Walker Consulting Solutions ' ' This code builds a sample Alpha Protocol control string, opens COM4 ' serial port, writes the string to the opened port and closes the port. '------------------------------------------------------------------------------- DIM bbMode AS STRING DIM bbColor AS STRING DIM bbText AS STRING DIM bbString AS STRING DIM returnval AS INTEGER DIM autobaud AS STRING autobaud = CHR$(0) + CHR$(0) + CHR$(0) + CHR$(0) + CHR$(0) 'autobaud NULL characters bbMode = "a" ' mode = rotate bbColor = CHR$(28) + "Z" + "40FFFF" ' extended RGB color (whitish blue) 'This program can be run from the command line by typing the name of the executable to display 'the default text or a custom message can be included after the executable name. bbText = "Betabrite Prism Test v3.0 by Walker Consulting Solutions www.WalkerConsulting.net" IF LEN(COMMAND$) > 0 THEN bbText = COMMAND$ ELSE PRINT "Type your custom message after the command line call to this program" END IF PRINT "DISPLAY PROPERTIES" PRINT "Display Mode = " + bbMode PRINT "Display Color = " + bbColor PRINT "Display Text = " + bbText PRINT "" 'build simple Alpha transmission packet (Letters in parens reference Alpha protocol document) bbString = autobaud 'autobaud NULL characters (A) bbString = bbString + CHR$(1) 'SOH character (B) bbString = bbString + "Z" 'Type Code: All Signs (C) bbString = bbString + "00" 'Sign Address: Broadcast (D) bbString = bbString + CHR$(2) 'STX Character (E) bbString = bbString + "A" 'Command Code: A - TEXT file (F) bbString = bbString + "A" 'File Label: A (G-B) bbString = bbString + CHR$(27) 'ESC Character (G-C) bbString = bbString + " " 'Display Position (reqd, ignored on 1-line signs) (G-D) bbString = bbString + bbMode 'Display mode (from variable above) (G-E) bbString = bbString + bbColor + bbText 'ASCII Message (G-G) bbString = bbString + CHR$(4) 'EOT Character (H) PRINT "Write bbString = " + bbString ON ERROR GOTO Handler FF = FREEFILE OPEN "COM4:9600,N,8,1" FOR OUTPUT AS #1 IF errnum = 0 THEN PRINT "COM4 opened." 'K$ = INPUT$(1) 'END Handler: errnum = ERR PRINT "CODE: "; errnum RESUME NEXT WRITE #1, bbString CLOSE #1 'Uncomment the SYSTEM call to automatically close the window after the message has been sent 'Leave it commented to show debugging information 'SYSTEM