You are not logged in.

IAO

Beginner

  • "IAO" is male
  • "IAO" started this thread

Posts: 38

Date of registration: May 25th 2013

Location: Venezuela

Occupation: Electronic

  • Send private message

1

Sunday, June 2nd 2013, 9:18pm

Some programs to share

Hi to all....
RXTX serial port rs232 and Jabaco Send

I want to make several simple programs to share with you. I hope to continue contributing to expand the forum.

You should read this post first before running the program.
Link rxtx Jabaco solution


When the program loads, it sends a message. When you press the button, it sends a message.
I used COM3 with Jabaco program. HyperTerminal with COM4.
See capture: cap1.png
I made comments to the original lines of rxtx java code.

This program in my computer with winxp-sp3 worked well.

My native language is Spanish.
Please do not ask questions here. It is very difficult for me to explain. ;)

I hope you enjoy this program.
With this program you can understand how to call java libraries.

Nice day to all people :)




.
IAO has attached the following image:
  • cap1.png
IAO has attached the following file:
  • rxtx-jabaco.zip (31.67 kB - 279 times downloaded - latest: Dec 2nd 2019, 9:00am)

This post has been edited 10 times, last edit by "IAO" (Jun 7th 2013, 2:54am)


IAO

Beginner

  • "IAO" is male
  • "IAO" started this thread

Posts: 38

Date of registration: May 25th 2013

Location: Venezuela

Occupation: Electronic

  • Send private message

2

Friday, June 7th 2013, 2:57am

Some programs to share

Hi....
RXTX serial port rs232 and Jabaco Receive

Very difficult for me. The program is not perfect.
The program works but I have to improve a lot. The main idea of receiving data, it works fine.

Remember:
You should read this post first, before running the program.
Link rxtx Jabaco solution

Very brief explanation.
1- run the jabaco program com3 and hyperTerminal program com4
2- hoh sorry you need: "Virtual Serial Port Driver" program, to conect virtual ports com3 and com4.
3- click "Search Send" button: send message to hyperterminal.
4- click "Search Receive" button: Here is a problem.
click "Search Receive" button, go hyperterminal write 1, then click again the same button.
Is difficult to explain this.
Displays a message window. Click Ok.
go hyperterminal write 22222223333334444446666 etc. and click "Search Receive" button.
Displays a message window. Click Ok.
Its all.
The number 1 = led green, the number 0 = led grey


It is very difficult to receive data with RXTX.
Inside the file. "Zip", placed original java rxtx TwoWaySerialComm.java

I hope you like it a bit :S
Greetings to all :)


.

IAO has attached the following image:
  • Cap1.png
IAO has attached the following file:

This post has been edited 6 times, last edit by "IAO" (Jun 14th 2013, 7:20pm)


IAO

Beginner

  • "IAO" is male
  • "IAO" started this thread

Posts: 38

Date of registration: May 25th 2013

Location: Venezuela

Occupation: Electronic

  • Send private message

3

Friday, June 7th 2013, 3:04am

Some programs to share

Hi...

Calculate Capacitor
Remember that I am not an expert programmer.
I changed my VB6 code to Jabaco. This working fine. You can improve it.
I have to make some improvements.
I hope you can enjoy it.



.
IAO has attached the following image:
  • cap1.png
IAO has attached the following file:
  • proCapacitor.zip (14.66 kB - 260 times downloaded - latest: Dec 3rd 2019, 8:57pm)

IAO

Beginner

  • "IAO" is male
  • "IAO" started this thread

Posts: 38

Date of registration: May 25th 2013

Location: Venezuela

Occupation: Electronic

  • Send private message

4

Friday, June 14th 2013, 2:53pm

Hi....

above on the second publication, Jabaco program with rxtx receiving from hyperterminal.
Here code: Form1

Jabaco Source

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
'''======================================================================================
Option Explicit

Import gnu#io#*  '***Import RXTX gnu.io.*;
Import java#io#* '***Import java.io.*;
Import java#util#Collection

Dim saludo1 As String = "Hello Jabaco! - TheButton" & vbCrLf
  
'***Java: Static CommPortIdentifier portId;
Dim portId As CommPortIdentifier 
'***Java: static SerialPort serialPort;
Dim serialPort As SerialPort
'***Java: Thread		 readThread;
Dim readThread As Thread
'***Java:  InputStream	 inputStream;
Dim inputStream As InputStream
Dim outputStream As OutputStream
'***Java: InputStream toin 
Dim toin As java#io#InputStream 
	
Dim str1 As String = ""
Dim items1 As String


Public Sub Form_Load()
'***Java: Boolean  portFound = False;
Dim portFound As Boolean 
'***Java: String   defaultPort = "COM1";
Dim defaultPort As String = "COM3" '''"COM1" "COM2" "COM4"

'***Java: portList = CommPortIdentifier.getPortIdentifiers();
Dim portList As java#util#Enumeration = CommPortIdentifier.getPortIdentifiers() 

'***Java: while (portList.hasMoreElements()) {
Do While portList.hasMoreElements()
  '***Java: portId = (CommPortIdentifier) portList.nextElement();  
 	 portId = Cast(portList.nextElement(), CommPortIdentifier)
  	
  
  '***Java: If (portId.getPortType() == CommPortIdentifier.PORT_SERIAL) {
  If (portId.getPortType() = CommPortIdentifier.PORT_SERIAL) Then
    	'***Java: If (portId.getName().equals(defaultPort)) {
    	If portId.getName().equals(defaultPort) Then   
    	'***Java: System.out.println("Found port: " + defaultPort);
    	Text1.Text = Text1.Text + "Found port: " + defaultPort + vbCrLf  
    	
    	'***Java: portFound = True;
    	portFound = True
    	'***Java: SimpleRead reader = New SimpleRead();
    	'reader = SimpleRead  
    	End If
   End If 
    	

 	items1 = portId.getName()
 '*** Ports to combobox and listbox
  lstCommPorts.AddItem items1
  ComboBox1.AddItem items1 	
  str1 = str1 & items1 & vbCrLf	
   
 Loop
 
 '***Coloca COM3 en ComboBox1 
 ComboBox1.Parent.setSelectedIndex(1) '(-1)

'***Java: If (!portFound) {	
If portFound = "" Then
'***Java: System.out.println("port " + defaultPort + " not found.");
 	lstCommPorts.AddItem "no port found!"
  ComboBox1.AddItem  "not found!" 
 	str1 = "no port found!"
End If
 	
End Sub

Public Sub Command1_Click()
 
   'Command1.Caption = "Disable"
   'Command1.Enabled = False

 	items1 = portId.getName()
 	
Dim portList As java#util#Enumeration = CommPortIdentifier.getPortIdentifiers()  
  Do While portList.hasMoreElements()
  '***Java: portId = (CommPortIdentifier) portList.nextElement();  
 	 portId = Cast(portList.nextElement(), CommPortIdentifier)
    	
   '***Java: If (portId.getName().equals("COM3")) {
   If portId.getName().equals("COM3") Then '("COM3") Then
   
   '***Java: serialPort = (SerialPort) portId.open("SimpleWriteApp", 2000);
   serialPort = Cast(portId.open("SimpleWriteApp", 2000), SerialPort)
   
   outputStream = serialPort.getOutputStream()
   
   serialPort.setSerialPortParams(9600, serialPort.DATABITS_8, _
   	serialPort.STOPBITS_1, serialPort.PARITY_NONE)
   
   '***Send to serial port.
   outputStream.write(saludo1)
   
   End If 
   Loop
   serialPort.close()
  	
End Sub
   
Public Sub Command2_Click()
'***Java: void connect ( String portName ) throws Exception 
Dim portName As String = "COM3"
'***Java: CommPortIdentifier portIdentifier = CommPortIdentifier.getPortIdentifier(portName);
Dim portIdentifier As CommPortIdentifier 
portIdentifier = CommPortIdentifier.getPortIdentifier(portName) 


'***Java: if ( portIdentifier.isCurrentlyOwned() )
 If portIdentifier.isCurrentlyOwned() Then
    	MsgBox "Error: Port is currently in use"
 	Else
 	'***Java: CommPort commPort = portIdentifier.open(this.getClass().getName(),2000);   
 	Dim commPort As CommPort
 	commPort = portIdentifier.open(getClass().getName(),2000)

 	'***Java: if( commPort instanceof SerialPort ) '***java.util.Collection  java#util#Collection
 	If IsClass(commPort, SerialPort) Then 'commPort = CommPort.getName() Then
         	
    	'***Java: SerialPort serialPort = (SerialPort) commPort;
    	serialPort = Cast(commPort, SerialPort) 
    	'***Java: serialPort.setSerialPortParams(57600,SerialPort.DATABITS_8,SerialPort.STOPBITS_1,SerialPort.PARITY_NONE);
    	serialPort.setSerialPortParams(57600, serialPort.DATABITS_8, _
          	serialPort.STOPBITS_1, serialPort.PARITY_NONE)  

    	'***Java: InputStream toin = serialPort.getInputStream();
    	'***toin = serialPort.getInputStream()
    	toin = serialPort.getInputStream()              	
 	Else
   	MsgBox "Error: Only serial ports are handled by this example."    	
 	End If	
 End If


Dim leido As Integer

'***Java: while ( ( len = this.toin.read(buffer)) > -1 )
Do While(toin.available() > 0)
leido = toin.read() 
List1.AddItem CChar(leido) 

'***If you want To change the BackColor of an Shape, be sure, 
'***that you have Set the BackStyle To vbSolid before. 
If CChar(leido) = "1" Then Shape1.BackColor = RGB(0, 255, 0)
If CChar(leido) = "0" Then Shape1.BackColor = RGB(128, 128, 128)


'java#lang#System.out.println(New String(buffer,0,len1))
Text1.Text = Text1.Text & toin.read() & vbCrLf  
Loop

End Sub

Public Sub Command3_Click()
On Error Resume Next
   serialPort.close() 
End Sub

Private Sub Form_Unload(Cancel As Integer) 
On Error Resume Next
'***Here you need jabaco_rev103.jar or higher
If MsgBox ("Quit?", vbCritical Or vbOKCancel,"Title") = 2 Then Exit Sub 
   Me.Parent.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE)
'***
   serialPort.close()
   CAll End
   system.exit(0)
End Sub


The importance of this code is to understand how a problem was solved.The code Help us.
Make the perfect code is your job. ;)
I hope you like it.
Greetings to all


.

This post has been edited 7 times, last edit by "IAO" (Jun 27th 2013, 6:21am)


IAO

Beginner

  • "IAO" is male
  • "IAO" started this thread

Posts: 38

Date of registration: May 25th 2013

Location: Venezuela

Occupation: Electronic

  • Send private message

5

Monday, June 24th 2013, 2:30pm

Some programs to share

Hi to all...
Inpout32.dll LPT reader and writer

This was my first program made in VB6. I translated it to Jabco.
I wanted to use the library RXTX, but it was very easy to move to Jabaco. I was too lazy to use rxtx.
I wanted to do this with Jacob (java com bridge), but it was easy to move to Jabaco. I did not need Jacob.
Some notes are in Spanish. sorry!
Inpout32.dll file not mine, I found it on the internet 10 years ago.
Entries made with '*** VB6: indicate original code in VB6.

Jabaco Source

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
Option Explicit
'***NOTE: Important!!
'***Copy Inpout32.dll  to \Windows\system32\

'*** Here worked well.
'***VB6: Declare Sub Out Lib "Inpout32.dll" Alias "Out32" (ByVal PortAddress As Integer, ByVal Value As Integer)
Private Winapi Function Out Lib "Inpout32.dll" Alias "Out32" (ByVal PortAddress As Integer, ByVal Value As Integer)
'***VB6: Declare Function Inp Lib "Inpout32.dll" Alias "Inp32" (ByVal PortAddress As Integer) As Integer
Private Winapi Function Inp Lib "Inpout32.dll" Alias "Inp32" (ByVal PortAddress As Integer) As Integer

Dim Puerto As Integer
Dim BE(0 To 7)  As Integer

Private Sub Form_Load()
'***Genera el contenido del combo.
Port.AddItem "LPT1 - (378)"
Port.AddItem "LPT2 - (278)"
Port.AddItem "LPT3 - (3BC)"
Port.ListIndex = 0 
End Sub

Private Sub Port_Click()
'***Apunta el puerto a utilizar.
If Port.ListIndex = 0 Then Puerto = &H378
If Port.ListIndex = 1 Then Puerto = &H278
If Port.ListIndex = 2 Then Puerto = &H3BC
End Sub

Private Sub Timer1_Timer()
'***Lee el dato del puerto.
Dim x As Integer
x = Inp(Puerto)  

'***Desglosa los bits restantes.
If x > 127 Then BE(7) = 1: x = x - 128 Else BE(7) = 0  '0 'Invertido
If x > 63  Then BE(6) = 1: x = x - 64  Else BE(6) = 0  '1
If x > 31  Then BE(5) = 1: x = x - 32  Else BE(5) = 0  '1
If x > 15  Then BE(4) = 1: x = x - 16  Else BE(4) = 0  '1
If x > 7   Then BE(3) = 1: x = x - 8   Else BE(3) = 0  '1
'***Agregado por mi
If x > 3 Then BE(2) = 1: x = x - 4 Else BE(2) = 0	'1
If x > 1 Then BE(1) = 1: x = x - 2 Else BE(1) = 0	'1
If x > 0 Then BE(0) = 1: x = x - 1 Else BE(0) = 0	'1

'***Controla los Led's.
Dim ciclo As Integer
For ciclo = 0 To 7
   If BE(ciclo) = 0 Then 
  	'***VB6: LE(Ciclo).Picture = LoadPicture(App.Path + "\res\lg1.png")
  	LE(ciclo).Picture = Lg1Png '***you have to add lg1.png as Jabaco-resource
  	Leer_lpt.Refresh       	'***a future framework-version will refresh it automatically
   Else 
  	'***VB6: LE(Ciclo).Picture = LoadPicture(App.Path + "\res\lr1.png")
  	LE(ciclo).Picture = Lr1Png '***you have to add lr1.png as Jabaco-resource
  	Leer_lpt.Refresh       	'***a future framework-version will refresh it automatically
   End If
Next Ciclo


End Sub


The importance of this code is to understand how a problem was solved.The code help us.
Make the perfect code is your job. ;)
I hope you like it.
Greetings to all and best wishes.

proLeerLPT = proReadLPT (leer = read)



.
IAO has attached the following image:
  • cap1.png
IAO has attached the following files:
  • proLeerLPT.zip (46.39 kB - 186 times downloaded - latest: Dec 4th 2019, 7:04pm)
  • proWriteLPT.zip (17.14 kB - 217 times downloaded - latest: Nov 28th 2019, 6:39pm)

This post has been edited 6 times, last edit by "IAO" (Jun 29th 2013, 2:56am)


IAO

Beginner

  • "IAO" is male
  • "IAO" started this thread

Posts: 38

Date of registration: May 25th 2013

Location: Venezuela

Occupation: Electronic

  • Send private message

6

Saturday, June 29th 2013, 3:52am

Some programs to share

Hi...

I was angry because JavaComBridge (jacob) not reading an unregistered DLL.
I found Jawin, and loaded inpout32.dll.

Jawin <==Download here.

put jawin.dll in /windows/system32
put inpout32.dll in /windows/system32
put jawin.jar in jabaco project folder and press F1 to load library.

copy/paste Form1 jabaco
Use this program in combination with proLeerLPT(above) to monitor the output LPT

Jabaco Source

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
Option Explicit

Import org#jawin#COMException
Import org#jawin#FuncPtr
Import org#jawin#ReturnFlags


Private Sub Form_Load()
'*** LPT1=(&H378)(888), LPT2=(&H278)(632), LPT3=(&H3BC)(956)
Dim g As Integer
Dim metodo1 As FuncPtr 
metodo1 = Null 

   metodo1 = New FuncPtr("Inpout32.dll","Out32")
        
   '***Los dos trabajan bien
   'g = metodo1.invoke_I(888,255,ReturnFlags.CHECK_HRESULT)  'En Decimal
   g = metodo1.invoke_I(&H378,15,ReturnFlags.CHECK_HRESULT)  'En Hexadecimal
   
   System.exit(0)
    
End Sub


Here with java code and remember add library jawin.jar
You need a program to read your LPT output.(proLeerLPT.zip = proReadLPT.zip (leer = read))

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
mport org.jawin.COMException;
import org.jawin.FuncPtr;
import org.jawin.ReturnFlags;

//***FUNCIONANDO BIEN.
public class JawinDLL {

    /*** @param args the command line arguments */
    public static void main(String[] args) throws COMException{
        //***TODO code application logic here
        FuncPtr metodo = null;
        metodo = new FuncPtr("Inpout32.dll","Out32");   
        
        //***Los dos trabajan bien
        //Integer g = metodo.invoke_I(888,15,ReturnFlags.CHECK_HRESULT);  //En Decimal
        Integer g = metodo.invoke_I(0x378,1,ReturnFlags.CHECK_HRESULT);   //En Hexadecimal
        //System.out.println(g); //****VB6:(&H378 = 888)
    }
}


Jabaco helped me alot to understand how to make a Java program. I love jabaco :thumbsup: :)
I am a very lucky man :thumbsup: :thumbsup: :thumbsup:

Greetings to all and best wishes.



.

This post has been edited 6 times, last edit by "IAO" (Jun 29th 2013, 4:16am)


IAO

Beginner

  • "IAO" is male
  • "IAO" started this thread

Posts: 38

Date of registration: May 25th 2013

Location: Venezuela

Occupation: Electronic

  • Send private message

7

Monday, July 1st 2013, 11:18pm

Hi...

I wanted to know how to make a java program with the framework jabaco.jar.
Thank you mr. theuserbl. Today I have an example made ​​by Mr. theuserbl and I want to share.

You should read this link before making this test. Controls with Events without GUI Designer

I use Netbeans IDE 7.3, winxp sp3, java sdk1.7, jabaco.jar rev-105.
Make an empty project and put these three files in the \src folder.
Add library "jabaco.jar" to the project, and Run de app :)


Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
//***name the file: Resources.java
import VBA.VBEnumClass;

public class Resources extends VBEnumClass 
{

    public Resources() 
    {
    }

    public Resources(int i) 
    {
        super(i);
    }

    public Resources(long l) 
    {
        super(l);
    }

    public Resources(String s) 
    {
        super(s);
    }
}




Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
//***name the file: Module1.java
import VB.AbstractForm;
import VBA.VBArray;

public class Module1 
{

    public static Form1 Form1 = new Form1();

    public static void main(String args[]) 
    {
        Throwable Err = null;
        VBA.VBArrayString myArgs = new VBArray();
        //myArgs = VBArray.createVBArray(args);
        Form1.SetDefaultClose();
        Form1.Show();
    }

    public Module1() 
    {
    }
}


Source code

1
//***name the file: Form1.java


The third file is very long, do not let me publish it.
Download the WithoutGUIDesigner.zip, there are the sources. (Up on the link)


This program works well.

Thanks mr. theuserbl. Many thanks :) :thumbup:

Greetings to all and best wishes.

.

This post has been edited 4 times, last edit by "IAO" (Jul 1st 2013, 11:34pm)


IAO

Beginner

  • "IAO" is male
  • "IAO" started this thread

Posts: 38

Date of registration: May 25th 2013

Location: Venezuela

Occupation: Electronic

  • Send private message

8

Saturday, July 6th 2013, 8:27pm

Some programs to share

Hi...

I translate other program vb6 to jabaco. It show sine in picture

Copy/paste in Form1

Jabaco Source

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
Option Explicit

Dim cx As Integer, cy As Integer
Dim cx1 As Integer, cy1 As Integer
Dim i As Integer, j As Long 
Dim dato(1000) As Long

'***Const pi = 3.14159265358979
Const pi = Atn(1)*4


Private Sub Command1_Click()
    j = 0

    Command1.Caption = "Draw && Send "
    Command1.Enabled = False
    
    For i = 0 To cx
        j = cy * Sin(12 * i * (pi / cx))

        dato(i + 1) = (cy / 2) - (j / 2) 
        '***VB6: Picture1.Line (i, dato(i))-(i, dato(i + 1)), vbBlue  '((&HFFFFFF / (i + 1)))
        Picture1.ForeColor = RGB(255,0,0) '***color red
        Picture1.Line(i, dato(i), i, dato(i + 1), False, RGB(255,0,0)) 
        Form1.Refresh
        
    Next i
   
    Command1.Enabled = True
    Command1.Caption = "Dibuje"

End Sub

Private Sub Form_Load()
    cy = Picture1.ScaleHeight   
    cx = Picture1.ScaleWidth  
     
    '***Axes x,y 
    Picture1.ForeColor = RGB(0,0,0)    '***color black
    Picture1.Line(120,2,120,118,False)
    Picture1.Line(2,60,230,60,False)  
                                       
    Command1.Caption = "Dibuje"
    
End Sub

Private Sub Form_Terminate()   
     'End
     System.exit(0)
End Sub


This program works well.
Greetings to all and best wishes.


.
IAO has attached the following image:
  • cap1.png

This post has been edited 1 times, last edit by "IAO" (Jul 6th 2013, 8:34pm)


IAO

Beginner

  • "IAO" is male
  • "IAO" started this thread

Posts: 38

Date of registration: May 25th 2013

Location: Venezuela

Occupation: Electronic

  • Send private message

9

Monday, July 8th 2013, 2:24pm

Some programs to share

Hi...

Scanner Method RXTX serial port rs232

Jabaco Send Receive


I do not give many explanations you already know.
F1 RXTX Library to load.
3 buttom, 1 text1, 1 label1 and run.
copy/paste to form1.

Jabaco Source

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
Option Explicit

Import gnu#io#*  '***Import RXTX gnu.io.*;
Import java#io#* '***Import java.io.*;
Import java#util#*
Import java#util#Collection#*

Dim 	greeting As String = "Hello Jabaco forum!!! " & vbCrLf

Dim portId As CommPortIdentifier 
Dim serialPort As SerialPort     
Dim readThread As Thread         
Dim inputStream As InputStream  
Dim outputStream As OutputStream
Dim scanner As Scanner          
Dim printStream As PrintStream     

'***=============================================================================
Private Sub Form_Load()

MsgBox "Remember click on SearchPort&Connect Buttom"

End Sub

Public Sub Command1_Click()
  
  Command1.Caption = "Disable"
  Command1.Enabled = False
  
  Dim puerto As CommPort
  Dim portList As java#util#Enumeration = CommPortIdentifier.getPortIdentifiers()
  portId = Null
  
  Do While portList.hasMoreElements()
 	 portId = Cast(portList.nextElement(), CommPortIdentifier)
   If portId.getName().equals("COM3") Then 
     '***Break
     Exit Do 
   End If    
  Loop
      

  serialPort = Cast(portId.open("PuertoSerial", 2000), SerialPort)
  serialPort.setSerialPortParams(9600, serialPort.DATABITS_8, _
  serialPort.STOPBITS_1, serialPort.PARITY_NONE)
          
  scanner = New Scanner(serialPort.getInputStream())
  printStream = New PrintStream(serialPort.getOutputStream())  
End Sub

Public Sub Command2_Click()
'***Envía cadena por puerto serial.
If Text1.Text = "" Then
MsgBox "Write Something and Send"
Else
printStream.write(Text1.Text) + vbCrLf
End If

End Sub

Public Sub Command3_Click()
Do While(Not scanner.hasNextInt())
   scanner.close()
   scanner = Null
   scanner = New Scanner(serialPort.getInputStream())
Loop

Dim valor As Integer 
valor = scanner.nextInt()     
Label1.setText(valor)
  
End Sub


Worked fine on my computer.
The program does not check errors.
Press "SearchPort & Connect" before sending or receiving something.
Program no receive more than three numbers.(123 or 555 or 1, 9, 22 ) not (5555555, 456456464) etc.

Best wishes.
IAO has attached the following image:
  • Cap1.png

This post has been edited 3 times, last edit by "IAO" (Jul 8th 2013, 2:36pm)


IAO

Beginner

  • "IAO" is male
  • "IAO" started this thread

Posts: 38

Date of registration: May 25th 2013

Location: Venezuela

Occupation: Electronic

  • Send private message

10

Sunday, July 14th 2013, 7:39pm

Some programs to share

Hi...

Here's a working example.
To receive in Jabaco with mscomm32.ocx in ModeText.
(Not ModeBinary)


To understan Look here first.
MSComm32 with Jabaco and Jacob
Put in designer editor: 2 Buttoms, 1 Text1, 1 Label1 and 1 RichTextBox1
(Remember F1 to load Jacob Library)

Jabaco Source

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
Option Explicit
'Import com#jacob#activeX#ActiveXComponent
Import com#jacob#activeX#* 
Import com#jacob#com#* 

Dim oInBufferCount As String
Dim MSComm1 As ActiveXComponent   

'***==========================================================================================
Private Sub Form_Load()

'***Funcionando así
Set MSComm1 = New ActiveXComponent("MSCOMMLib.MSComm.1")

    Dispatch.put(MSComm1, "RThreshold", 1)
    Dispatch.put(MSComm1, "InputLen", 0)  '***read the entire contents of the receive buffer.
    Dispatch.put(MSComm1, "InputMode", 0) '0 TextMode, 1 BinarieMode
    Dispatch.put(MSComm1, "InBufferSize", 512)
    Dispatch.put(MSComm1, "CommPort", 3)        '***Select comm port to open
    Dispatch.put(MSComm1, "Settings", "57600,N,8,1")
    '***Make sure DTR line is low to prevent Stamp reset
    Dispatch.put(MSComm1, "DTREnable", False)
    Dispatch.put(MSComm1, "RTSEnable", True)
    '***Aquí abre el PuertoSerial    
    Dispatch.put(MSComm1, "PortOpen", True)      

   'Dispatch.put(MSComm1, "Output", "Holaaaa" & vbCrLf)  '***<====To Send puerto serial

End Sub

Public Sub Command1_Click()
   Dispatch.put(MSComm1, "PortOpen", False)     '***<====Aquí Close SerialPort
   System.exit(0)

End Sub

Public Sub Command2_Click()

oInBufferCount = Dispatch.call(MSComm1, "InBufferCount")

If oInBufferCount > 0 Then
Dim a As String = Dispatch.call(MSComm1, "Input")   'TextMode String. Working!. Variant not work.

Text1.Text = Text1.Text & a & vbCrLf  '***OK
Label1 = Label1 & a & vbCrLf          '***OK
RichTextBox1.Text =  RichTextBox1.Text & a & vbNewLine  '***OK
End If 

Dispatch.put(MSComm1, "InBufferCount", 0)   
End Sub


That's all.
Greetings.

.
IAO has attached the following image:
  • Cap1.png

This post has been edited 8 times, last edit by "IAO" (Jul 14th 2013, 8:44pm)


Rate this thread
WoltLab Burning Board