Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (476)
Games in Android Showcase (106)
games submitted by our members
Games in WIP (533)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  New to Java, communicating through a Com port  (Read 1955 times)
0 Members and 1 Guest are viewing this topic.
Offline pierson

Junior Newbie





« Posted 2006-03-21 18:46:40 »

Hi,

I got an idea from an electronics magazine that I'd like to try.

Basically, take an old exercycle, non-electronic, and hook a hall-effect sensor and magnet to get RPM readings. I built the sensor, and the cable plugs into my com port, which supplies the electricity for it. It works!

The code that the magazine supplies is some custom IDE that appears to be related to .NET (the instructions say that .NET must be loaded. However, I want to learn Java and create a game interface. The sample program is pretty basic; it has a racetrack and moves the player and three computer players around the track.

I've got two older books on Java, and neither has any information specific to Com ports.

Here's the code for the test program:

'Exercise Bike Sensor Test
func main()

   gconst chBike 1
   dim Rot as integer
   clearall
   
   if ComOpen(chBike,baud=9600,port = 1) = 0 then
     MsgBox("Error Opening Com Port")
     end
     endif
     
   'Power up the connector
   ComDTR chBike,1
   
Loop:
   if ComBuff(chBike) > 0 then
       Rot = Rot + 1
       Print val(ComInput(chBike)),"Count="+Rot
   endif
   
   DoEvents
   goto Loop

endfunc

If anyone knows what the specifics are for communicating through the Com port and could share, I'd appreciate it.

I've downloaded NetBeans 5.0 IDE. If there's a better IDE, I'd like your opinion.
Offline Riven
« League of Dukes »

JGO Overlord


Medals: 743
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #1 - Posted 2006-03-21 19:32:40 »

Take a look at the javacomm API, it's outdated and has annoying habits (like forcing files in java.ext.dirs)

You can take out the annoying bit by decompiling, changing, recompiling, but... that's illegal... suit yourself.



Anyway, with that API you shuold get it running in notime, it handles I/O with the usual java.io.InputStream/OutputStream's

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Offline noblemaster

JGO Ninja


Medals: 20
Projects: 10


Age of Conquest makes your day!


« Reply #2 - Posted 2006-03-21 19:35:09 »

NetBeans is fine.

What the serial port connection concerns. You need to download the "Java Communications API" to connect to the serial port. It's not included with the Java Standard Edition. Go to: http://java.sun.com/products/javacomm/.

Version 2.0 was not very much to my liking. However, 3.0 is out now. It's really easy to use. There is docu on that web site too.

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Riven
« League of Dukes »

JGO Overlord


Medals: 743
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #3 - Posted 2006-03-21 19:41:59 »

About V3.0:

"Implementations of the API are currently available for Solaris SPARC, Solaris x86, and Linux x86"

 Roll Eyes


How hard can it be to add support for win32/64

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Offline pierson

Junior Newbie





« Reply #4 - Posted 2006-03-21 20:13:10 »

I was about to ask, which of the three will work for me. Oh, well.  Roll Eyes
Offline Anon666

Junior Member




aka Abuse/AbU5e/TehJumpingJawa


« Reply #5 - Posted 2006-03-21 21:06:28 »

About V3.0:

"Implementations of the API are currently available for Solaris SPARC, Solaris x86, and Linux x86"

 Roll Eyes


How hard can it be to add support for win32/64

Not exactly what people consider 'the big 3' Smiley
Offline rdcarvallo

Senior Member


Projects: 5
Exp: 15 years


2D Java games forever!


« Reply #6 - Posted 2006-03-21 23:01:17 »

Is somewhere a Iink to download a version (V2.x) for windows??
The Sun Page only has V3.0 for download.

     Rafael.-
Offline Vage

Senior Newbie




learning++;


« Reply #7 - Posted 2006-03-29 04:00:59 »

I had this issue when trying to figure out a way to sync a christmas light display using 16 SSRs with a computer. I ended up using the parallel port, but I found the Java communications API to rather unsuitable. Even though it for the parallel port, it does show you how to use some simple JNI if you didn't know before:

http://www.hytherion.com/beattidp/comput/pport.htm

I'm sure you could adapt that design, find some C code that'll ouput to a serial port on a Windows machine, and voila: You're in business.

Personally, you could strap me into a mech cockpit with 47 virtual HUD displays, two complex hand controls and foot pedals and I'd be grinning like the gamer freak I am.
Offline noblemaster

JGO Ninja


Medals: 20
Projects: 10


Age of Conquest makes your day!


« Reply #8 - Posted 2006-03-29 04:38:52 »

I found a copy here:
http://wind.lcs.mit.edu/download/java/javacomm20-win32.zip

However, 2.0 is rather unstable. Sometimes connecting to the serial port does not work for no reason. Trust me, I tried!!!

We actually bought the SerialIO library which works without problems. It's $50 for Windows:
https://serialio.com//store/index.php?cPath=21_29


I would suggest try out JavaComm 2.0. If you have problems, download the SerialIO library. You won't need to change any code. You just switch javacomm.jar with serialio.jar and it works like a dream! Note: I am not affiliated with SerialIO.

Offline Jeff

JGO Coder




Got any cats?


« Reply #9 - Posted 2006-03-29 04:42:38 »

About V3.0:

"Implementations of the API are currently available for Solaris SPARC, Solaris x86, and Linux x86"

 Roll Eyes


How hard can it be to add support for win32/64

Well you could write it, then....  Wink

Got a question about Java and game programming?  Just new to the Java Game Development Community?  Try my FAQ.  Its likely you'll learn something!

http://wiki.java.net/bin/view/Games/JeffFAQ
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Alan_W

JGO Knight


Medals: 8
Projects: 3


Java tames rock!


« Reply #10 - Posted 2006-03-29 06:26:29 »

I'm not sure how easy it will be to do in Java, as this type of application often tends to abuse the comm port, using some of the handshake lines as direct polled I/O (I don't know whether this is the case here).  This requires some quite low level programming, which I guess is where you question comes from.  The windows API does support this kind of thing.  In the worst case, this might need a bit of JNI programming.  Alternatively you could use a PIC (www.microchip.com) to measure the frequency & communicate it via proper RS232 protocol, but this is quite complex to do.  (You can get simple programmer kits from maplin).  The JNI approach (if necessary) would be cheaper.

However, I haven't checked whether you can do this with the standard Java API, so best to take a longer look at that first Smiley

Alan

/Edited as I didn't read the question properly the first time.

Time flies like a bird. Fruit flies like a banana.
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

pw (22 views)
2014-07-24 01:59:36

Riven (20 views)
2014-07-23 21:16:32

Riven (17 views)
2014-07-23 21:07:15

Riven (20 views)
2014-07-23 20:56:16

ctomni231 (48 views)
2014-07-18 06:55:21

Zero Volt (44 views)
2014-07-17 23:47:54

danieldean (35 views)
2014-07-17 23:41:23

MustardPeter (38 views)
2014-07-16 23:30:00

Cero (53 views)
2014-07-16 00:42:17

Riven (52 views)
2014-07-14 18:02:53
HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54

HotSpot Options
by Roquen
2014-05-06 15:03:10

Escape Analysis
by Roquen
2014-04-29 22:16:43

Experimental Toys
by Roquen
2014-04-28 13:24:22
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!