Forums Register Login

Getting available ports using Javax.comm

+Pie Number of slices to send: Send
Hi friends,
I was trying to get the available port using the following sample program.But I couldnt get any output.
can u help me?
Program;

import java.io.*;
import java.util.*;
import javax.comm.*;
public class SimpleWrite {
static Enumeration portList;
static CommPortIdentifier portId;
static String messageString = "Hello, world!\n";
static SerialPort serialPort;
static OutputStream outputStream;
public static void main(String[] args) throws NoSuchPortException
{

portList = CommPortIdentifier.getPortIdentifiers();

while (portList.hasMoreElements())
{
portId = (CommPortIdentifier) portList.nextElement();

if (portId.getPortType() == CommPortIdentifier.PORT_SERIAL)
{
// if (portId.getName().equals("COM1")) {
if (portId.getName().equals("/dev/term/a"))
{
try {
serialPort = (SerialPort)
portId.open("SimpleWriteApp", 2000);
} catch (PortInUseException e) {}
try {
outputStream = serialPort.getOutputStream();
} catch (IOException e) {}
try {
serialPort.setSerialPortParams(9600,
SerialPort.DATABITS_8,
SerialPort.STOPBITS_1,
SerialPort.PARITY_NONE);
} catch (UnsupportedCommOperationException e) {}
try {
outputStream.write(messageString.getBytes());
} catch (IOException e) {}
}
}
}
}
}
===============

I am getting the following error.(It tells there is no elements in the Enumeration)
Error loading win32com: java.lang.UnsatisfiedLinkError: no win32com in java.library.path
You may have just won ten million dollars! Or, maybe a tiny ad.
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 1109 times.
Similar Threads
Problem with COMM API
Serial I/O
Need Suggestions..
Getting available ports using Javax.comm
Caught java.lang.UnsatisfiedLinkError
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 08:55:41.