Serial Comm Port

Post

Posted
Rating:
#1 (In Topic #1152)
Regular
Umbridge is in the usergroup ‘Regular’
 Good afternoon) I'm trying to figure out the serial port. I would like to use only graphical ActiveX settings as in VB6. The task is simply to send the contents of textbox1 to the serial port when the button is pressed. Tell me the minimum possible program for this. The port has already been specified. It remains to understand the sequence and syntax. As I understand it, you do not need to open the port as in VB6.

Image

(Click to enlarge)

Online now: No Back to the top

Post

Posted
Rating:
#2
Guru
BruceSteers is in the usergroup ‘Guru’
I have never used SerialPort control but it looks like it inherits Stream.class

I assume you have read all the help on the wiki…
SerialPort @ /comp/gb.net/serialport - Gambas Documentation
Stream @ /comp/gb/stream - Gambas Documentation

to write to a stream it is done something like this..
(I think the stream MUST be Opened before writing but i could be wrong.

Code (gambas)

  1.  
  2. Dim sMyText As String = "This is some text"
  3.  
  4. SerialPort1.Open  ' open the port for communication
  5.  
  6. Write #SerialPort1, sMyText    ' write the text to the stream
  7.  
  8. Print #SerialPort1, "Using Print will add linefeed to end of string"
  9.  
  10. SerialPort1.Close  ' close the port after use.
  11.  
  12.  

But like i say i only assume this is how serialport works as i do not have anything to test the code on.
Online now: No Back to the top

Post

Posted
Rating:
#3
Regular
Umbridge is in the usergroup ‘Regular’
 It seems that the problem is not in the syntax, but in the system) try this simple example for yourself)

Image

(Click to enlarge)

Online now: No Back to the top
1 guest and 0 members have just viewed this.