Last active
June 25, 2022 15:04
-
-
Save TristanOrta/50eccd8f52eea58debbb689a072cf185 to your computer and use it in GitHub Desktop.
Connection and reading of serial port to PowerBuilder
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//if the port is open it closes | |
if ol_mscomm.object.PortOpen then | |
ol_mscomm.object.PortOpen = false | |
end if | |
//port reading process | |
try | |
ol_mscomm.object.CommPort = as_puerto | |
ol_mscomm.object.Settings = as_config_puerto | |
ol_mscomm.object.Handshaking= 0 | |
ol_mscomm.object.NullDiscard = True //Avoid reading null character | |
ol_mscomm.object.RThreshold = 1 //When reading this number of characters OnComm is raised, this is the total length of the data string including CF + LF | |
ol_mscomm.object.InputLen = ol_mscomm.object.RThreshold //The amount defined in RThreshold is read and emptied | |
ol_mscomm.object.RTSEnable = True | |
ol_mscomm.object.PortOpen = True | |
return true | |
// If there is an error, the system prints the error in a MessageBox and adds a message about the problem. | |
catch(OLERuntimeError e) | |
MessageBox("Error", e.Description ) | |
MessageBox("Error", "The port is offline or in use by another application " ) | |
//return | |
end try |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment