General

apc220 + java

userHead scofielcl 2014-05-30 00:30:32 4364 Views4 Replies
Hello . I want to read from the com port bytes , but the program does not respond.

I am using apc220 (radio module). and arduino uno. http://fritzing.org/projects/wireless-a ... ith-apc220

java programm :
Code: Select all

package com_port;

import jssc.SerialPort;
import jssc.SerialPortEvent;
import jssc.SerialPortEventListener;
import jssc.SerialPortException;

public class Com_port {

    private static SerialPort serialPort;

    public static void main(String[] args) {
        //???????? ? ??????????? ??? ?????
        serialPort = new SerialPort("COM7");
        try {
            //????????? ????
            serialPort.openPort();
            //?????????? ?????????
            serialPort.setParams(SerialPort.BAUDRATE_9600,
                                 SerialPort.DATABITS_8,
                                 SerialPort.STOPBITS_1,
                                 SerialPort.PARITY_NONE);
            //???????? ?????????? ?????????? ???????
            serialPort.setFlowControlMode(SerialPort.FLOWCONTROL_RTSCTS_IN | 
                                          SerialPort.FLOWCONTROL_RTSCTS_OUT);
            //????????????? ????? ??????? ? ?????
            serialPort.addEventListener(new PortReader(), SerialPort.MASK_RXCHAR);

        }
        catch (SerialPortException ex) {
            System.out.println(ex);
        }
    }

    private static class PortReader implements SerialPortEventListener {

        public void serialEvent(SerialPortEvent event) {
            if(event.isRXCHAR() && event.getEventValue() > 0){
                try {
                    //???????? ????? ?? ??????????, ???????????? ?????? ? ?.?.
                    byte[] data = serialPort.readBytes();                   
                    System.out.println(data[0]);
                }
                catch (SerialPortException ex) {
                    System.out.println(ex);
                }
            }
        }
    }
}
Read with arduino IDE or c# correct.

I need help.
2014-06-05 23:21:33 [quote="scofielcl"]
https://code.google.com/p/java-simple-s ... loads/list

I am thinking , necessary to establish specific settings port.
[/quote]
Looks interesting, but I don't speak Java  :P

are you planning on putting it on a web?
I'd like to try this :D
userHeadPic Jose
2014-05-30 22:25:46 Hello Grey.
Setting for apc220 is correct , exactly.
I do read and write with apc200 use c# and arduino IDE.

Hello Jose.

https://code.google.com/p/java-simple-s ... loads/list

I am thinking , necessary to establish specific settings port.
userHeadPic scofielcl
2014-05-30 21:55:49 hey,

Seems that you require a library for this project.

Where did you get this library from ?

Cheers^^
userHeadPic Jose
2014-05-30 19:26:13 Welcome scofielcl,

I am not familiar with Java, but I thinks it is a good idea to configure APC220 parameter first.
Here is APC220 wiki page.
After the configuration, it is better to test communication first.
userHeadPic Grey.CC