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 |
This post has been edited 5 times, last edit by "IAO" (Jun 27th 2013, 5:35am)
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 |
This post has been edited 5 times, last edit by "IAO" (Jun 28th 2013, 3:15am)
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); } } |
This post has been edited 1 times, last edit by "IAO" (Jun 29th 2013, 4:37am)
Jabaco Source |
|
1 |
Dispatch.put (MSComm1, "Output", "Hellooo" & vbCrLf)
|
This post has been edited 3 times, last edit by "IAO" (Jul 14th 2013, 7:46pm)
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 |
This post has been edited 2 times, last edit by "IAO" (Jul 24th 2013, 11:26pm)
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 |
Quoted
Before:_____________Now:
18f1d7e_____________-83
55e55f______________-92
2c1e6b______________-16
3bc257______________75
1dd3812_____________96
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 } } |