Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.IOException;
- import com.pi4j.io.gpio.exception.UnsupportedBoardType;
- import com.pi4j.io.serial.*;
- public class SerialComms {
- public static void main(String[] args) {
- // make sure serial console is disabled on the pi
- final Serial serial = SerialFactory.createInstance();
- // create serial config object
- SerialConfig config = new SerialConfig();
- // set default serial settings (device, baud rate, flow control, etc)
- //
- // use the DEFAULT com port on the Raspberry Pi
- try {
- config.device(SerialPort.getDefaultPort()).baud(Baud._38400).dataBits(DataBits._8).parity(Parity.NONE)
- .stopBits(StopBits._1).flowControl(FlowControl.NONE);
- serial.open(config);
- while (true) {
- serial.write("wew lad");
- System.out.println("wew");
- }
- } catch (UnsupportedBoardType e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (InterruptedException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement