Revision: 5998
http://sourceforge.net/p/jnode/svn/5998
Author: epr
Date: 2013-11-12 15:21:28 +0000 (Tue, 12 Nov 2013)
Log Message:
-----------
Added named pipe viewer, for viewing COM1 output of JNode in Hyper-V
Added Paths:
-----------
trunk/core/src/test/org/jnode/test/core/NamedPipeViewer.java
Added: trunk/core/src/test/org/jnode/test/core/NamedPipeViewer.java
===================================================================
--- trunk/core/src/test/org/jnode/test/core/NamedPipeViewer.java (rev 0)
+++ trunk/core/src/test/org/jnode/test/core/NamedPipeViewer.java 2013-11-12 15:21:28 UTC (rev 5998)
@@ -0,0 +1,45 @@
+package org.jnode.test.core;
+
+import java.io.Console;
+import java.io.File;
+import java.io.IOException;
+import java.io.RandomAccessFile;
+
+public class NamedPipeViewer {
+
+ public static void main(String[] args) throws IOException {
+ File pipeFile = new File("\\\\.\\pipe\\jnode-com1");
+ final RandomAccessFile raf = new RandomAccessFile(pipeFile, "rw");
+
+ Thread readThread = new Thread(new Runnable() {
+ @Override
+ public void run() {
+ int ch;
+ try {
+ while ((ch = raf.read()) >= 0) {
+ System.out.print((char)ch);
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ });
+ readThread.start();
+
+ // Write to kdb
+ int ch;
+ System.out.println("Started. Press q to exit");
+ while ((ch = System.in.read()) >= 0) {
+ System.out.println("read " + (char)ch);
+ if (ch == 'q') {
+ break;
+ }
+ raf.write(ch);
+ }
+
+ System.out.println("Closing...");
+ readThread.interrupt();
+ raf.close();
+ }
+
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|