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

Thursday, June 27th 2013, 2:45am

Testing with MsComm32.ocx and JaCoB (RESOLVED)

Hi to all....

I'm starting to do tests with the MScomm32 and JaCoB (Java to COM Bridge).
I put here a small advance. I continue testing.
Only this seems to work.

Copy jacob.jar and jacob-1.17-M2-x86.dll to project folder.
mscomm32.ocx in /windows/system32 and registered witn regsvr32 command
Press F1 to add jacob.jar to project.

Jabaco Source

1
2
3
4
5
6
7
8
9
10
11
12
Option Explicit
Import com#jacob#activeX 
Import com#jacob#com 

Private Sub Form_Load()
Dim MSComm1 As ActiveXComponent
Set MSComm1 = New ActiveXComponent("MSCOMMLib.MSComm.1")

MsgBox "MSCOMM Loaded"
System.exit(0)

End Sub


So far it seems to work well. Much remains to be done.
But if someone wants to try here I leave. I'll keep trying.
I know this will work only on windows os.

See you soon....


.

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


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

Thursday, June 27th 2013, 5:06am

Helloooooo :)

I'm a lucky man.
I think it is working well.
I am very happy. :) :thumbsup:
I thought I was going to take a month to finish this.

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
Option Explicit

Import com#jacob#activeX#* 
Import com#jacob#com#* 

Private Sub Form_Load()
   Dim oMSComm As ActiveXComponent
   Set oMSComm = New ActiveXComponent("MSCOMMLib.MSComm.1") 
   Dim MSComm1 As Dispatch
   Set MSComm1 = oMSComm.getObject()

    Dim a As String
    Dim b As String
    Dim c As String
 
    a = Dispatch.call(MSComm1, "CommPort")
    b = Dispatch.call(MSComm1, "Settings")
    c = Dispatch.call(MSComm1, "PortOpen")

    MsgBox ("MSCOMM Port: " & a & VBCrLf & "Settings: " & b & VBCrLf & _
                  "Port Open: " & c & VBCrLf)

    System.exit(0)

End Sub


Now I'll have to do something more realistic.

Other things to try (RThreshold, SThreshold, InputMode, InBufferSize, DTREnable, RTSEnable, InputLen)

Hope you like this example. And it can be useful for someone.

I did tests with windows seven 32 bits, but not work.
My computer uses winxp sp3.
That's all

.

This post has been edited 5 times, last edit by "IAO" (Jun 28th 2013, 3:15am)


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

Saturday, June 29th 2013, 4:31am

Hi...

If somebody need java code, I put here.
Remember load library jacob.jar

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
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
import com.jacob.activeX.*;
import com.jacob.com.*;

/*** This class uses the the Jacob tech to use and interact with a Com component 
 in a java application */

public class ReadDLL 
{   
    
    public static void main(String[] args)
    {
        ActiveXComponent MSComm1 = new ActiveXComponent("MSCOMMLib.MSComm.1");        
        System.out.println("The Library been loaded, and an activeX component been created");
        
        String a, b, c, d, e, f, g, h ,i, j;
       
        Dispatch.put(MSComm1, "RThreshold", 1);
        //Dispatch.put(MSComm1, "InputLen", 0);
        Dispatch.put(MSComm1, "InputMode", 1);
        Dispatch.put(MSComm1, "InBufferSize", 512);
        Dispatch.put(MSComm1, "CommPort", 3);        //***Select comm port to open
        Dispatch.put(MSComm1, "Settings", "57600,N,8,1");
        Dispatch.put(MSComm1, "DTREnable", false);
        Dispatch.put(MSComm1, "RTSEnable", true);
        
         //***using the functions from the library:        
          a = Dispatch.call(MSComm1,"CommPort").toString();
          System.out.println("Puerto: " + a); 
        
          b = Dispatch.call(MSComm1,"Settings").toString();
          System.out.println("Settings: " + b);
          
          c = Dispatch.call(MSComm1,"PortOpen").toString();
          System.out.println("PortOpen: " + c);
        
          d = Dispatch.call(MSComm1,"SThreshold").toString();
          System.out.println("SThreshold: " + d);
          
          e = Dispatch.call(MSComm1,"RThreshold").toString();
          System.out.println("RThreshold: " + e);          

          f = Dispatch.call(MSComm1,"InputMode").toString();
          System.out.println("InputMode: " + f);
          
          g = Dispatch.call(MSComm1,"InBufferSize").toString();
          System.out.println("InBufferSize: " + g);
        
          h = Dispatch.call(MSComm1,"InputLen").toString();
          System.out.println("InputLen: " + h);
          
          i = Dispatch.call(MSComm1,"DTREnable").toString();
          System.out.println("DTREnable: " + i);
          
          j = Dispatch.call(MSComm1,"RTSEnable").toString();
          System.out.println("RTSEnable: " + j);          
    }
}


It worked in my computer winxp sp3.
I am very happy, happy.

nice days to all...


.

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


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

Sunday, July 14th 2013, 3:19pm

Hi...

I thought Jabaco program, was complete. But two things missing.
Send and Receive to RS232. The most important

I was trying to send and receive with mscomm32.ocx

In Jabaco to send with mscomm32.ocx is easy:

Jabaco Source

1
Dispatch.put (MSComm1, "Output", "Hellooo" & vbCrLf)


To receive data I have a few problems.

I will continue testing to receive data with mscomm32.ocx

Greatings

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

Sunday, July 14th 2013, 7:20pm

I moved this publication for this link. Please excuse me
Program MScomm Receive Jabaco

To receive in Jabaco with mscomm32.ocx in ModeText. (Not ModeBinary)



.

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


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

Wednesday, July 24th 2013, 11:15pm

Hi...
I have done many tests. In binary mode not working.
The program gives me no errors, but does not receive in binary mode.
I'm tired of testing with this.
I will test in java.
I'm sure the problem is Jabaco, and the arrays.

If anyone wants to test, here I leave my last attempt in binary mode.

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
Option Explicit
'Import com#jacob#activeX#ActiveXComponent
Import com#jacob#activeX#* 
Import com#jacob#com#* 

'***Variables MSCOMm32.ocx
Dim oInBufferCount As String

Dim MSComm1 As ActiveXComponent   


'***========================
Public Sub Command2_Click()

Dim i As Integer 
oInBufferCount = Dispatch.call(MSComm1, "InBufferCount")
 
'Dim a(20) As Variant  
'Dim a1(20) As java#lang#Byte
 Dim a2(20) As String

Dim sa As SafeArray
Set sa = New SafeArray((com#jacob#com#Variant.VariantVariant), 20) '***20 array size
Dim sab As Variant
sab = sa.toVariantArray() ' toIntArray() 'toByteArray() 


If oInBufferCount > 0 Then
	For i = 0 To sab.getUBound() 'UBound(a2) ' '.length 'UBound() 
	sab(i) = Dispatch.call(MSComm1, "Input") '.toSafeArray() '.toDispatch()
	RichTextBox1.Text =  RichTextBox1.Text & sab(i) '& vbNewLine  

	'***Mode text work ("InputMode", 0)
	'a2(i) = Dispatch.call(MSComm1, "Input")
	'RichTextBox1.Text =  RichTextBox1.Text & a2(i)

	Next i
End If

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



Private Sub Form_Load()
'***Funcionando así: Dim MSComm1 As ActiveXComponent   
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", 1) '0 TextMode, 1 BinaryMode
    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)      
End Sub



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


greetings


.

This post has been edited 2 times, last edit by "IAO" (Jul 24th 2013, 11:26pm)


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 29th 2013, 4:09pm

Hi...

I have the same problem with Java. I receive data in text mode, but not receive data in binary mode.

The problem is not with Jabaco, the problem is in my brain. :)


greetings...

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

Wednesday, July 31st 2013, 9:29pm

Hiiiii.

I am a triple donkey. :D
The program works. Now receive with binary_mode.

Remember JaCoB library with F1. Work well.

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
Option Explicit
Import com#jacob#activeX#* 
Import com#jacob#com#* 

Dim oInBufferCount As Integer 
Dim MSComm1 As ActiveXComponent   

'***==========================================================================================
Public Sub Command2_Click()

Dim i As Integer 

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

Dim sa As SafeArray
Set sa = New SafeArray((com#jacob#com#Variant.VariantVariant), 20) '***20 Size array
Dim sab As Variant
sab = sa.toVariantArray() 

If oInBufferCount > 0 Then
   
   For i = 0 To UBound(sab) 
   
   sa = Dispatch.get(MSComm1, "Input").toSafeArray()
   
   RichTextBox1.Text =  sa.toByteArray()  

   Next i
End If

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

Private Sub Form_Load()

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", 1) '0 TextMode, 1 BinaryMode
    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)  '***<====Send to port serial

End Sub

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

End Sub



greetings...

.

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

Saturday, August 3rd 2013, 1:53pm

Hi...

This Java program helped me to complete the program in Jabaco.
The Java program had a problem to display the output.
Yesterday I could improve the program to display the output with String values.

Quoted


Before:_____________Now:
18f1d7e_____________-83
55e55f______________-92
2c1e6b______________-16
3bc257______________75
1dd3812_____________96


Java Code: Receive rs232 with MSComm32.ocx and JaCoB

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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import com.jacob.activeX.*;
import com.jacob.com.*;
import java.io.*;

public class RecibirBinario2 
{
    public static void main(String[] args) throws Exception
    {
        ComThread.InitSTA();
        ActiveXComponent MSComm1 = new ActiveXComponent("MSCOMMLib.MSComm.1");

        //***Variables para el MSComm1
        int oInBufferCount;
  
        Dispatch.put(MSComm1, "RThreshold", 1);
        Dispatch.put(MSComm1, "InputLen", 0);
        Dispatch.put(MSComm1, "InputMode", 1);          //***0 TextMode, 1 BinaryMode
        Dispatch.put(MSComm1, "InBufferSize", 512);
        Dispatch.put(MSComm1, "CommPort", 3);          //***Select comm port to open
        Dispatch.put(MSComm1, "Settings", "57600,N,8,1");
        Dispatch.put(MSComm1, "DTREnable", false);
        Dispatch.put(MSComm1, "RTSEnable", true);
        
        Dispatch.put(MSComm1, "PortOpen", true);       //***<====open SerialPort
 
        oInBufferCount = Dispatch.call(MSComm1, "InBufferCount").toInt();        

SafeArray sa = new SafeArray(com.jacob.com.Variant.VariantVariant, 20);
SafeArray sab = sa;

          //***BinaryMode 
          if( oInBufferCount > 0 )
          {
              for(int i = 0; i < sab.getUBound(); i++) //length()    
              {                
                  //***Funcionando Bien 
                  sa = Dispatch.get(MSComm1, "Input").toSafeArray(false);
                  byte[] bA = (byte[])(sa.toByteArray());
                  String value = new String(bA);
                  System.out.println(value);         
              }
          }
          
          //Dispatch.put(MSComm1, "Output", "Holaaaa");  //***<====send port serial       
          //Dispatch.put(MSComm1, "InBufferCount", 0);    //***Put zero inbuffer   
          //Dispatch.put(MSComm1, "PortOpen", false);     //***<====close port serial             
    }
}



That's all...
greetings...


.

Rate this thread
WoltLab Burning Board