BowlerKernel
java-bowler
src
main
java
com
neuronrobotics
sdk
dyio
DyIOOutputStream.java
Go to the documentation of this file.
1
/*******************************************************************************
2
* Copyright 2010 Neuron Robotics, LLC
3
* Licensed under the Apache License, Version 2.0 (the "License");
4
* you may not use this file except in compliance with the License.
5
* You may obtain a copy of the License at
6
*
7
* http://www.apache.org/licenses/LICENSE-2.0
8
*
9
* Unless required by applicable law or agreed to in writing, software
10
* distributed under the License is distributed on an "AS IS" BASIS,
11
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
* See the License for the specific language governing permissions and
13
* limitations under the License.
14
******************************************************************************/
15
package
com.neuronrobotics.sdk.dyio;
16
17
import
java.io.IOException;
18
import
java.io.OutputStream;
19
20
import
com.neuronrobotics.sdk.common.ByteList;
21
22
// TODO: Auto-generated Javadoc
26
public
class
DyIOOutputStream
extends
OutputStream {
27
29
DyIOChannel
chan;
30
36
public
DyIOOutputStream
(
DyIOChannel
channel) {
37
chan = channel;
38
}
39
49
public
void
write
(
ByteList
bl)
throws
IOException {
50
if
(chan.
getMode
() !=
DyIOChannelMode
.
USART_TX
) {
51
throw
new
IOException(
"The DyIO is not configured with a UART Tx mode"
);
52
}
53
//Bypassing the channel on transmit to prevent re-transmits
54
//chan.getDevice().send(new SetChannelValueCommand(chan.getNumber(),bl));
55
//System.out.println("Sending ByteList: "+bl.asString());
56
while
(bl.size()>0){
57
ByteList
b;
58
if
(bl.size()>20){
59
b =
new
ByteList
(bl.popList(20));
60
}
else
{
61
b =
new
ByteList
(bl.popList(bl.size()));
62
}
63
//System.out.println("Sending ByteList: "+b.asString());
64
chan.
setValue
(b);
65
}
66
}
67
68
/* (non-Javadoc)
69
* @see java.io.OutputStream#write(int)
70
*/
71
@Override
72
public
void
write
(
int
b)
throws
IOException {
73
write
(
new
ByteList
(b));
74
}
75
76
/* (non-Javadoc)
77
* @see java.io.OutputStream#write(byte[])
78
*/
79
@Override
80
public
void
write
(
byte
[] b)
throws
IOException {
81
write
(
new
ByteList
(b));
82
}
83
84
/* (non-Javadoc)
85
* @see java.io.OutputStream#write(byte[], int, int)
86
*/
87
@Override
88
public
void
write
(
byte
[] b,
int
off,
int
len)
throws
IOException {
89
write
(
new
ByteList
(b).getBytes(off, len));
90
}
91
}
com.neuronrobotics.sdk.common.ByteList
Definition:
ByteList.java:32
com.neuronrobotics.sdk.dyio.DyIOChannel
Definition:
DyIOChannel.java:39
com.neuronrobotics.sdk.dyio.DyIOChannel.setValue
boolean setValue(int value)
Definition:
DyIOChannel.java:563
com.neuronrobotics.sdk.dyio.DyIOChannel.getMode
DyIOChannelMode getMode(boolean resync)
Definition:
DyIOChannel.java:238
com.neuronrobotics.sdk.dyio.DyIOOutputStream
Definition:
DyIOOutputStream.java:26
com.neuronrobotics.sdk.dyio.DyIOOutputStream.write
void write(byte[] b, int off, int len)
Definition:
DyIOOutputStream.java:88
com.neuronrobotics.sdk.dyio.DyIOOutputStream.write
void write(byte[] b)
Definition:
DyIOOutputStream.java:80
com.neuronrobotics.sdk.dyio.DyIOOutputStream.DyIOOutputStream
DyIOOutputStream(DyIOChannel channel)
Definition:
DyIOOutputStream.java:36
com.neuronrobotics.sdk.dyio.DyIOOutputStream.write
void write(int b)
Definition:
DyIOOutputStream.java:72
com.neuronrobotics.sdk.dyio.DyIOOutputStream.write
void write(ByteList bl)
Definition:
DyIOOutputStream.java:49
com.neuronrobotics.sdk.dyio.DyIOChannelMode
Definition:
DyIOChannelMode.java:29
com.neuronrobotics.sdk.dyio.DyIOChannelMode.USART_TX
USART_TX
Definition:
DyIOChannelMode.java:56
Generated by
1.9.1