From: <jo...@us...> - 2008-04-01 22:26:19
|
Revision: 221 http://mspsim.svn.sourceforge.net/mspsim/?rev=221&view=rev Author: joxe Date: 2008-04-01 15:25:56 -0700 (Tue, 01 Apr 2008) Log Message: ----------- fixed bug and debug-output for NC. Modified Paths: -------------- mspsim/se/sics/mspsim/util/NetworkConnection.java Modified: mspsim/se/sics/mspsim/util/NetworkConnection.java =================================================================== --- mspsim/se/sics/mspsim/util/NetworkConnection.java 2008-04-01 08:19:47 UTC (rev 220) +++ mspsim/se/sics/mspsim/util/NetworkConnection.java 2008-04-01 22:25:56 UTC (rev 221) @@ -137,8 +137,11 @@ } else { try { cthr[i].output.write((byte) data.length); - cthr[i].output.write(buf); - if (DEBUG) System.out.println("NetworkConnection: wrote " + data.length + " bytes"); + cthr[i].output.write(buf, 0, data.length); + if (DEBUG) { + System.out.println("NetworkConnection: wrote " + data.length + " bytes"); + printPacket(buf, data.length); + } } catch (IOException e) { e.printStackTrace(); cthr[i].close(); @@ -148,6 +151,13 @@ } } + private void printPacket(byte[] data, int len) { + for (int i = 0; i < len; i++) { + System.out.print("" + Utils.hex8(data[i]) + " "); + } + System.out.println(); + } + private boolean connect(int port) { try { Socket socket = new Socket("127.0.0.1", port); @@ -201,7 +211,11 @@ len = input.read(); if (len > 0) { input.readFully(buffer, 0, len); - if (DEBUG) System.out.println("NetworkConnection: Read packet with " + len + " bytes"); + if (DEBUG) { + System.out.println("NetworkConnection: Read packet with " + len + " bytes"); + printPacket(buffer, len); + } + dataReceived(buffer, len); } } catch (IOException e) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |