|
VBScript to Serial Port Communication John from United States [3 posts] |
11 year
|
Is there a way to be running a VBscript with an if statement, and in the if statement send a command through the serial port?
Example
if cogy > 100 then
'send command "SS<cr>" through the COM port
end if
|
|
|
Carl from Your Country [1447 posts] |
11 year
|
John,
Not directly from the VBScript ... what you do is setup the appropriate variables in VBScript and use them within the Serial module. (Think of separating logic and communication into different modules).
So you would have a VBScript module with
if GetVariable("COG_Y") > 100 then
SetVariable "serial_cmd", "SS<cr>"
end if
and then in the Serial module you would have
[serial_cmd]
as what gets sent to your serial device. Note the use of a variable to communicate between the VBscript and serial module. You CANNOT call the serial module directly ... you can only configure what is sent. Thus all things like baud, port, etc. are setup using the serial module interface instead of in code.
See attached robofile as example (note we left out the actual tracking to keep things simple).
STeven.
program.robo
|
|