You are not logged in.

A1880

Intermediate

  • "A1880" is male

Posts: 500

Date of registration: Jan 1st 2009

Location: Hanover, Germany

Occupation: Software Engineer

Hobbies: Hilbert Curves

  • Send private message

21

Tuesday, October 5th 2010, 12:45pm

Try this:

Jabaco Source

1
en = Cast(CommPortIdentifier.getPortIdentifiers(), CommPortEnumerator)


Greetings

A1880

htillmann

Beginner

  • "htillmann" is male

Posts: 30

Date of registration: Feb 25th 2009

Location: Beverungen / Weser

Occupation: Softwareentwicklung

  • Send private message

22

Tuesday, October 5th 2010, 3:12pm

rxtx with Jabaco

Hi A1880,

thanks for the tip.

compiling is Ok now:
rxtx is loaded:

Listening for transport dt_shmem at address: Jabaco20832921x686
Stable Library
=========================================
Native lib Version = RXTX-2.1-7
Java lib Version = RXTX-2.1-7


but then I get:

java.lang.IllegalAccessError: tried to access class gnu.io.CommPortEnumerator from class Form1
at Form1.Command1_Click(Form1.jsrc:14)
at Form1$CommandButton._Click(Form1.jsrc:41)
at VB.CommandButton.actionPerformed(CommandButton.jsrc)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2318)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236)
at java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:272)
at java.awt.Component.processMouseEvent(Component.java:6216)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3265)
at java.awt.Component.processEvent(Component.java:5981)
at java.awt.Container.processEvent(Container.java:2041)
at java.awt.Component.dispatchEventImpl(Component.java:4583)
at java.awt.Container.dispatchEventImpl(Container.java:2099)
at java.awt.Component.dispatchEvent(Component.java:4413)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4556)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4220)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4150)
at java.awt.Container.dispatchEventImpl(Container.java:2085)
at java.awt.Window.dispatchEventImpl(Window.java:2475)
at java.awt.Component.dispatchEvent(Component.java:4413)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
at VBA.JabacoEventQueque.dispatchEvent(JabacoEventQueque.java:20)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)

Any futher idea?
Thanks in advance.
Regards hubertus


A1880

Intermediate

  • "A1880" is male

Posts: 500

Date of registration: Jan 1st 2009

Location: Hanover, Germany

Occupation: Software Engineer

Hobbies: Hilbert Curves

  • Send private message

23

Tuesday, October 5th 2010, 3:38pm

What source code is Form1.jsrc:14 ?
This operation causes the exception.

Happy hacking

A1880

htillmann

Beginner

  • "htillmann" is male

Posts: 30

Date of registration: Feb 25th 2009

Location: Beverungen / Weser

Occupation: Softwareentwicklung

  • Send private message

24

Tuesday, October 5th 2010, 3:47pm

It is your suggestion

Source code

1
en = Cast(CommPortIdentifier.getPortIdentifiers(), CommPortEnumerator) 

A1880

Intermediate

  • "A1880" is male

Posts: 500

Date of registration: Jan 1st 2009

Location: Hanover, Germany

Occupation: Software Engineer

Hobbies: Hilbert Curves

  • Send private message

25

Tuesday, October 5th 2010, 4:03pm

Sorry, as mentioned before, I can't check this any further.

A1880

htillmann

Beginner

  • "htillmann" is male

Posts: 30

Date of registration: Feb 25th 2009

Location: Beverungen / Weser

Occupation: Softwareentwicklung

  • Send private message

26

Tuesday, October 5th 2010, 4:17pm

No problem,

having a solution, I'll post

HUbertus

Dr_Acula

Beginner

  • "Dr_Acula" is male

Posts: 8

Date of registration: Feb 22nd 2011

Location: Adelaide, Australia

Occupation: Medical practitioner

  • Send private message

27

Tuesday, February 22nd 2011, 5:05am

I have just downloaded jabaco and this is a very impressive program.

I am trying to add a serial port. I have read through this thread, and found the rxtxcomm program
I have extracted this to
C:\Program Files\Jabaco\serial\rxtx-2.1-7-bins-r2
and this directory contains several other directories, and it contains RxTxComm.jar

Next I have the code posted earlier.

Source code

1
2
3
4
5
6
7
Option Explicit
Import javax#comm


Public Sub Command1_Click()

   Dim cpi As CommPortIdentifier


but I get an error with the last line "Class CommPortIdentifier" not found.

I think this is importing the wrong file with 'Import javax#comm'. How do I import the correct serial port driver?

Many thanks.

A1880

Intermediate

  • "A1880" is male

Posts: 500

Date of registration: Jan 1st 2009

Location: Hanover, Germany

Occupation: Software Engineer

Hobbies: Hilbert Curves

  • Send private message

28

Tuesday, February 22nd 2011, 11:39am

You have to add all necessary *.jar archives to the project classpath.
Use Key F1 in the Jabaco IDE, followed by "add Jar-Archive".
You can check if a class is known by using the search function in the project classpath dialog.

Success!

A1880

Dr_Acula

Beginner

  • "Dr_Acula" is male

Posts: 8

Date of registration: Feb 22nd 2011

Location: Adelaide, Australia

Occupation: Medical practitioner

  • Send private message

29

Wednesday, February 23rd 2011, 6:28am

Thanks for the quick response A1880!

When I get this working I'm going to write this up as a "step by step" guide as this is a little complex.

I've added the file, and I've added the folder.

With this code I get an error in the last line

Source code

1
2
3
4
5
6
7
8
9
10
11
Option Explicit
Import javax#comm


Public Sub Command1_Click()

   Dim cpi As CommPortIdentifier 
   Dim ty As Integer  
   Dim s As String = ""
   MsgBox("start")
   Dim en As java#util#Enumeration = CommPortIdentifier.getPortIdentifiers() ' this gives an error


error

Quoted


java.lang.UnsatisfiedLinkError: no rxtxSerial in java.library.path


Attached is a screen shot of the F1

1) The bottom entry is a link to the entire directory.
2) The second to bottom link is supposed to link to the .jar file.
3) It does not seem possible to check the checkboxes in the main list - only the sub boxes - see the screen capture.
4) A search at the bottom does not find the file RXTXcomm.jar - see the error message.

Any help here is most appreciated.
Dr_Acula has attached the following image:
  • image1.jpg

A1880

Intermediate

  • "A1880" is male

Posts: 500

Date of registration: Jan 1st 2009

Location: Hanover, Germany

Occupation: Software Engineer

Hobbies: Hilbert Curves

  • Send private message

30

Wednesday, February 23rd 2011, 10:07am

The search facility of the project classpath dialog is meant for classes.
You entered a filename rather than a class.

Be aware of Jabaco's Cast() operation.
You might need it to convert object types.
Use the forum search to find examples for Cast().

I can imagine that "this is a little complex".
This is always the case for Java libraries involving native routines with hardware access.

Good luck!

A1880

Dr_Acula

Beginner

  • "Dr_Acula" is male

Posts: 8

Date of registration: Feb 22nd 2011

Location: Adelaide, Australia

Occupation: Medical practitioner

  • Send private message

31

Wednesday, February 23rd 2011, 1:27pm

Thanks for the advice.

This is turning out to be extremely complicated. There are many variables so one has to work through them all:

1) I found this on wikipedia These files can also include a Classpath entry, which identifies other JAR files for loading with the JAR. This entry consists of a list of absolute or relative paths to other JAR files. Although intended to simplify JAR use, in practice it turns out to be notoriously brittle, as it depends on all the relevant JARs being in the exact locations specified when the entry-point JAR was built. To change versions or locations of libraries, a new manifest is needed.

So I copied these instructions
http://www.jcontrol.org/download/readme_rxtx_en.html

  • unpack rxtx-*-win32.zip,
  • copy rxtxSerial.dll to %JAVA_HOME%\bin,
    (%JAVA_HOME% is the folder where JRE is installed on your system; e.g. c:\Program Files\Java\j2re1.4.1_01)
  • copy RXTXcomm.jar to %JAVA_HOME%\lib\ext
Of course, my computer has many instances of Java, so I searched the directory for the latest one and so rxtxserial.dll is in
C:\Program Files\Java\jdk1.6.0_21\bin
and
and I have rxtxcomm.jar in
C:\Program Files\Java\jdk1.6.0_21\lib\ext

2) The instructions at the beginning of the program
The example earlier in this thread is

Source code

1
2
Option Explicit
Import javax#comm


but there are suggestions to change this to something else. This website makes some suggestions
http://rxtx.qbang.org/wiki/index.php/Using_RXTX

But it says to change

Change the all occurences of the import javax.comm.*;


but we don't have that, we have javax#comm, so it is unclear whether to change this to
Import gnu#io
or some other syntax, eg Import gnu.io.rxtxcomm or Import gnu.io#rxtxcomm
I think I will use Import gnu#io because this autocompletes when you type gnu#

3) F1 and adding classes. I do not understand this. When you click on "Find Class", do you specify a .jar name, or do you specify just a filename, or a directory. What exactly is this searching for?

4) Adding a jar archive. F1 and "Add Jar-Archive" and it says it is searching for "files of type" "Jar-Archiv". Is this an extension? If so, I am not aware of an extension like this and a search does not find any files of this type. Scrolling through directories, the only files that are shown are ones ending in .jar. But above you said not to search for filenames, rather to search for classes. But a jar is an archive, and you can unzip and view the individual files with any zip program. So do we add the archive rxtxcomm.jar or not? I am assuming you do, because when I add this file, I get some very rapid messages on the screen about "importing".

5) This is my test code now

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
Option Explicit
'Import javax#comm
Import gnu#io


Public Sub Command1_Click()

   Dim cpi As CommPortIdentifier 
   Dim ty As Integer  
   Dim s As String = ""
   Dim en As java#util#Enumeration
   MsgBox("test1")
   ' = CommPortIdentifier.getPortIdentifiers()
   en = Cast(CommPortIdentifier.getPortIdentifiers(), CommPortEnumerator)
   MsgBox("test2")


I split the line with the Dim and setting the value as there was a comment earlier about casting.

The error is on this line en = Cast(CommPortIdentifier.getPortIdentifiers(), CommPortEnumerator)
and it says "no rxtxserial in java.library.path

So I still think the error is that jabaco does not yet know where the library is.

Any advice would be most helpful. Kind regards.

A1880

Intermediate

  • "A1880" is male

Posts: 500

Date of registration: Jan 1st 2009

Location: Hanover, Germany

Occupation: Software Engineer

Hobbies: Hilbert Curves

  • Send private message

32

Wednesday, February 23rd 2011, 3:07pm

First, you have to make sure that all relevant jar files are actually present in the list of project classpath jar archives.
"Jar-Archiv" is the german word for "jar archive". The file extension for jar archives is ".jar" by default.
Technically, jar files are zip files. You can open them using tools like Winzip or 7zip.

The search window in the bottom left of the classpath dialog is used to locate a certain class in the hierarchy of the various jar files.
Example: Searching for "Boolean" will show java#lang#Boolean. You can use a right-click context menu of your mouse to save this class fullname for
inserting it into your code. If a class search yields no hits, a jar file is still missing.

I you get errors related to java.library.path, a native *.dll library is not found. Make sure that the DLL is copied in a directory which is addressed by the PATH environment variable of your Windows. You can try to put it in the current working directory (cf. menu "Project" "Open Working Directory".

I hope this helps

Greetings

A1880

Dr_Acula

Beginner

  • "Dr_Acula" is male

Posts: 8

Date of registration: Feb 22nd 2011

Location: Adelaide, Australia

Occupation: Medical practitioner

  • Send private message

33

Thursday, February 24th 2011, 4:29am

Vielen Dank für deine Hilfe.

********** SUCCESS! ***************

I have got it working! It finds one parallel port, and three serial ports (two hardware, and one is a $2 USB to serial device).

Some of the answer came from here http://mango.serotoninsoftware.com/forum/posts/list/14.page

1) Put the .dll files in this directory C:\Program Files\Java\jdk1.6.0_21\jre\bin

The dll files are a) RxTxParallel.dll and b) rxTxSerial.dll
The "jdk1.6.0_21" part will change as Java is updated from time to time.
*** Very Important ***
do NOT put these files in the C:\Program Files\Java\jdk1.6.0_21\bin folder. Put them in the \jre\bin folder

2) Put the RxTxComm.jar in this folder: C:\Program Files\Java\jdk1.6.0_21\lib\ext and as noted in several discussion forums, you will need to create the \ext folder.

3) Type F1 in jabaco and "Add Jar Archive" and browse to this directory C:\Program Files\Java\jdk1.6.0_21\lib\ext and select the .jar file

4) To check that jabaco knows these files exist, down the bottom of that screen, in "Classname" type SerialPort and then check "Find Class". (You have to know what the name is to be able to search for it!! Searching for Serial will not work)

5) Use this code

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
Option Explicit
Import gnu#io

Public Sub Command1_Click()
   Dim cpi As CommPortIdentifier 
   Dim ty As Integer  
   Dim s As String = ""
   Dim en As java#util#Enumeration = CommPortIdentifier.getPortIdentifiers()
   Do While en.hasMoreElements()  
 cpi = Cast(en.nextElement(), CommPortIdentifier)
 ty = cpi.getPortType()
 If ty = CommPortIdentifier.PORT_PARALLEL Then
   s = s & "parallel port: "  
 Elseif ty = CommPortIdentifier.PORT_SERIAL Then
   s = s & "serial port: "
 Else
   s = s & "??? port: "
 End If
 s = s & cpi.getName() & vbCrLf
   Loop
   If s = "" Then
  s = "no port found!"
   End If
   MsgBox s
End Sub


The code on post 21 of this thread does not work for some reason.

The above code answers posts 24 and 25 on this thread

6) You can get the serial driver package here http://www.jcontrol.org/download/rxtx_en.html

Once again, thankyou so much to A1880.

Hopefully this post will help someone else in the future.

This post has been edited 1 times, last edit by "Dr_Acula" (Feb 24th 2011, 4:44am)


  • "santiago.barreiro" is male

Posts: 14

Date of registration: Jan 29th 2010

Location: Guayaquil, Ecuador

Occupation: Manager of a software company

Hobbies: Music player

  • Send private message

34

Tuesday, June 21st 2011, 10:26am

Great!
After months of not using JABACO due to me be unable to workout serial ports, I just fund that it have been solver. Thanks doctor.

joekaisaka

Beginner

Posts: 11

Date of registration: Feb 1st 2011

  • Send private message

35

Monday, July 25th 2011, 8:37pm

Hi Everybody

Congratulations Dr_Acula for your effort and dedication to solve this problem.

I have some questions :
1) How to Open the Serial Port ?
2) How to know if the port is already open ?
3) How to send a string ? (like msconn.output method)
4) How to obtain some info about the ports ? handshaking, velocity, setting...
5) Error handling.

I've found a code written in java, but I don't know port to jabaco.
http://www.devmedia.com.br/post-7171-Uti…-Parte-III.html
The page is in Portuguese, sorry... I'm brazilian.

Thanks In Advance

Rate this thread
WoltLab Burning Board