private String readLine(int fd, long addr, String prefix) throws IOException { if(LOGGER.isLoggable(FINEST)) LOGGER.finest("Reading "+prefix+" at "+addr); Memory m = new Memory(1); byte ch = 1; ByteArrayOutputStream buf = new ByteArrayOutputStream(); int i = 0; while(true) { if (i++ > LINE_LENGTH_LIMIT) { LOGGER.finest("could not find end of line, giving up"); throw new IOException("could not find end of line, giving up"); } long r = LIBC.pread(fd, m, new NativeLong(1), new NativeLong(addr)); ch = m.getByte(0); if (ch == 0) break; buf.write(ch); addr++; } String line = buf.toString(); if(LOGGER.isLoggable(FINEST)) LOGGER.finest(prefix+" was "+line); return line; } }
case kEdsDataType_Int8: //EdsInt8 case kEdsDataType_UInt8: //EdsUInt8 return (T) Byte.valueOf( memory.getByte( 0 ) ); case kEdsDataType_Int16: //EdsInt16 case kEdsDataType_UInt16: //EdsUInt16
private String readLine(int fd, long addr, String prefix) throws IOException { if(LOGGER.isLoggable(FINEST)) LOGGER.finest("Reading "+prefix+" at "+addr); Memory m = new Memory(1); byte ch = 1; ByteArrayOutputStream buf = new ByteArrayOutputStream(); int i = 0; while(true) { if (i++ > LINE_LENGTH_LIMIT) { LOGGER.finest("could not find end of line, giving up"); throw new IOException("could not find end of line, giving up"); } LIBC.pread(fd, m, new NativeLong(1), new NativeLong(addr)); ch = m.getByte(0); if (ch == 0) break; buf.write(ch); addr++; } String line = buf.toString(); if(LOGGER.isLoggable(FINEST)) LOGGER.finest(prefix+" was "+line); return line; } }
@Override public Object readFrom(Memory buffer, Class<?> type) { byte character = buffer.getByte(0); return character == 0 ? java.lang.Boolean.FALSE : java.lang.Boolean.TRUE; } @Override public Memory bufferForResult(Object methodCallResult) {
/** * Retrieves the state of a given line. * * @param line * The GPIO line * * @return A boolean representing the state. */ public boolean get( GpioLine line ) { return this.buffer.getByte( line.index ) == 1 ; }
@Override public Object readFrom(Memory buffer, Class<?> type) { return buffer.getByte(0); } @Override public Memory bufferForResult(Object methodCallResult) {
private static String readLine(FILE as, long p, String prefix) throws IOException { if(LOGGER.isLoggable(FINEST)) LOGGER.finest(String.format("Reading %s at %X",prefix,p)); seek64(as,p); Memory m = new Memory(1); ByteArrayOutputStream buf = new ByteArrayOutputStream(); int i=0; while(true) { if(LIBC.fread(m,1,1,as)==0) break; byte b = m.getByte(0); if(b==0) break; if((++i)%100==0 && LOGGER.isLoggable(FINEST)) LOGGER.finest(prefix +" is so far "+buf.toString()); buf.write(b); } String line = buf.toString(); if(LOGGER.isLoggable(FINEST)) LOGGER.finest(prefix+" was "+line); return line; }
private static String readLine(FILE as, long p, String prefix) throws IOException { if(LOGGER.isLoggable(FINEST)) LOGGER.finest(String.format("Reading %s at %X",prefix,p)); seek64(as,p); Memory m = new Memory(1); ByteArrayOutputStream buf = new ByteArrayOutputStream(); int i=0; while(true) { if(LIBC.fread(m,1,1,as)==0) break; byte b = m.getByte(0); if(b==0) break; if((++i)%100==0 && LOGGER.isLoggable(FINEST)) LOGGER.finest(prefix +" is so far "+buf.toString()); buf.write(b); } String line = buf.toString(); if(LOGGER.isLoggable(FINEST)) LOGGER.finest(prefix+" was "+line); return line; }
private static void printMemory(Memory memory) { System.out.println("Binary view:"); for (long i = 0; i < memory.getSize(); i++) { System.out.print(Integer.toBinaryString(memory.getByte(i))); System.out.print(' '); } System.out.println(); System.out.println("Octal view:"); for (long i = 0; i < memory.getSize(); i++) { System.out.print(Integer.toOctalString(memory.getByte(i))); System.out.print(' '); } System.out.println(); System.out.println("Hex view:"); for (long i = 0; i < memory.getSize(); i++) { System.out.print(Integer.toHexString(memory.getByte(i))); System.out.print(' '); } System.out.println(); }
private static String readLine(FILE as, long p, String prefix) throws IOException { if(LOGGER.isLoggable(FINEST)) LOGGER.finest(String.format("Reading %s at %X",prefix,p)); seek64(as,p); Memory m = new Memory(1); ByteArrayOutputStream buf = new ByteArrayOutputStream(); int i=0; while(true) { if(LIBC.fread(m,1,1,as)==0) break; byte b = m.getByte(0); if(b==0) break; if((++i)%100==0 && LOGGER.isLoggable(FINEST)) LOGGER.finest(prefix +" is so far "+buf.toString()); buf.write(b); } String line = buf.toString(); if(LOGGER.isLoggable(FINEST)) LOGGER.finest(prefix+" was "+line); return line; }
private static String readLine(final FILE as, final long p) { seek64(as, p); Memory m = new Memory(1); ByteArrayOutputStream buf = new ByteArrayOutputStream(); while (true) { if (CLibrary.INSTANCE.fread(m, 1, 1, as) == 0) { break; } byte b = m.getByte(0); if (b == 0) { break; } buf.write(b); } return buf.toString(); }
private String readLine(int fd, long addr, String prefix) throws IOException { if(LOGGER.isLoggable(FINEST)) LOGGER.finest("Reading "+prefix+" at "+addr); Memory m = new Memory(1); byte ch = 1; ByteArrayOutputStream buf = new ByteArrayOutputStream(); int i = 0; while(true) { if (i++ > LINE_LENGTH_LIMIT) { LOGGER.finest("could not find end of line, giving up"); throw new IOException("could not find end of line, giving up"); } LIBC.pread(fd, m, new NativeLong(1), new NativeLong(addr)); ch = m.getByte(0); if (ch == 0) break; buf.write(ch); addr++; } String line = buf.toString(); if(LOGGER.isLoggable(FINEST)) LOGGER.finest(prefix+" was "+line); return line; } }
@Override public int read() throws IOException { int i = checkChannel(); if (i == -1) { return -1; } Memory m = new Memory(1); int read = library.ssh_channel_read(channel, m, 1, stderr ? 1 : 0); if (read < 0) { throw new IOException("I/O Error"); } return m.getByte(0); }
int offset = 0; while(offset < size.getValue()){ while((ch = m.getByte(offset++))!='\0') baos.write(ch); lArgs.add(baos.toString());
int offset = 0; while(offset < size.getValue()){ while((ch = m.getByte(offset++))!='\0') baos.write(ch); lArgs.add(baos.toString());
int offset = 0; while (offset < size.getValue()) { while ((ch = m.getByte(offset++)) != '\0') { baos.write(ch);
byte reportID = m_InputReportMemory.getByte(0); m_InputReportBytesRead[0]--; m_InputReportMemory.read(1, m_InputReportBytes, 0, m_InputReportBytesRead[0]);
hr = OleAuto.INSTANCE.SafeArrayGetElement(this, paramIndices, mem); COMUtils.checkRC(hr); result = mem.getByte(0); break; case VT_UI2: