Verbindungsunterbrechung July 26, 2011 12:36AM |
Registered: 13 years ago Posts: 71 |
Re: Verbindungsunterbrechung July 26, 2011 12:50AM |
Registered: 14 years ago Posts: 7,505 |
Aller Anfang war schwer - Wolfstrap | Reprap-fab.org |
Re: Verbindungsunterbrechung July 26, 2011 12:52AM |
Registered: 14 years ago Posts: 3,742 |
Re: Verbindungsunterbrechung July 26, 2011 01:09AM |
Registered: 13 years ago Posts: 71 |
Re: Verbindungsunterbrechung July 26, 2011 02:14AM |
Registered: 14 years ago Posts: 3,742 |
Re: Verbindungsunterbrechung July 26, 2011 02:18AM |
Registered: 14 years ago Posts: 7,505 |
Aller Anfang war schwer - Wolfstrap | Reprap-fab.org |
Re: Verbindungsunterbrechung July 26, 2011 02:35AM |
Registered: 13 years ago Posts: 71 |
Re: Verbindungsunterbrechung July 26, 2011 07:40AM |
Registered: 14 years ago Posts: 3,742 |
private void openSerialConnection(String portName) { int baudRate = 19200; serialInStream = null; serialOutStream = null; //open our port. Debug.d("GCode opening port " + portName); Main.setRepRapPresent(false); try { CommPortIdentifier commId = CommPortIdentifier.getPortIdentifier(portName); port = (SerialPort)commId.open(portName, 30000); } catch (NoSuchPortException e) { Debug.d("Can't open port: " + portName + " - no RepRap attached."); return; } catch (PortInUseException e){ Debug.e("Port '" + portName + "' is already in use."); return; } Main.setRepRapPresent(true); //get our baudrate try { baudRate = Preferences.loadGlobalInt("BaudRate"); } catch (IOException e){} // Workround for javax.comm bug. // See [forum.java.sun.com] // FIXME: jvandewiel: is this workaround also needed when using the RXTX library? try { port.setSerialPortParams(baudRate, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); } catch (UnsupportedCommOperationException e) { Debug.d("An unsupported comms operation was encountered.\n" + e.toString()); return; } // Wait for baud rate change to take effect try {Thread.sleep(1000);} catch (Exception e) {} try { port.setFlowControlMode(SerialPort.FLOWCONTROL_NONE); } catch (Exception e) { // Um, Linux USB ports don't do this. What can I do about it? } try { port.enableReceiveTimeout(1); } catch (UnsupportedCommOperationException e) { Debug.d("Read timeouts unsupported on this platform"); } //create our steams try { OutputStream writeStream = port.getOutputStream(); serialInStream = port.getInputStream(); serialOutStream = new PrintStream(writeStream); } catch (IOException e) { Debug.e("GCodeWriter: Error opening serial port stream."); serialInStream = null; serialOutStream = null; return; } //arduino bootloader skip. Debug.d("Attempting to initialize Arduino/Sanguino"); try {Thread.sleep(1000);} catch (Exception e) {} for(int i = 0; i < 10; i++) serialOutStream.write('0'); try {Thread.sleep(1000);} catch (Exception e) {} return; }
Re: Verbindungsunterbrechung July 26, 2011 07:53AM |
Registered: 13 years ago Posts: 7,616 |
Generation 7 Electronics | Teacup Firmware | RepRap DIY |
Re: Verbindungsunterbrechung July 26, 2011 09:06AM |
Registered: 13 years ago Posts: 71 |
Re: Verbindungsunterbrechung July 26, 2011 09:29AM |
Registered: 14 years ago Posts: 3,742 |
Quote
Pfanne
Mein Ziel war es nicht dickköpfig zu sein