1 package eu.javaexperience.electronic.uartbus;
3 import java.io.ByteArrayOutputStream;
4 import java.io.DataOutputStream;
5 import java.io.IOException;
6 import java.math.BigInteger;
14 super(
new ByteArrayOutputStream());
17 public byte[] done()
throws IOException
20 ByteArrayOutputStream baos = (ByteArrayOutputStream) out;
21 byte[] ret = baos.toByteArray();
26 public void writePackedValue(
boolean signed, Number value)
throws IOException
28 if(value instanceof BigInteger)
30 writePackedValue(
signed, (BigInteger) value);
34 writePackedValue(
signed, value.longValue());
38 public void writeString(String val)
throws IOException
40 write(val.getBytes());
44 public void writePackedValue(
boolean signed, BigInteger value)
throws IOException
46 byte[] data =
new byte[
UartbusTools.calcPackReqBytes(
signed, value)];
51 public void writePackedValue(
boolean signed,
long value)
throws IOException
53 writePackedValue(
signed, BigInteger.valueOf(value));
56 public void writePackedValue(
boolean signed,
int value)
throws IOException
58 writePackedValue(
signed, BigInteger.valueOf(value));
61 public void writeAddress(
int val)
throws IOException
63 writePackedValue(
true, val);
66 public void writeAddressing(
int from,
int to)
throws IOException
72 public void appendCrc8()
throws IOException
75 ByteArrayOutputStream baos = (ByteArrayOutputStream) out;
79 public void writeObjects(Object... objects)
throws IOException