Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Sven Gestegård Robertz
LabComm
Commits
45b8e760
Commit
45b8e760
authored
Feb 07, 2014
by
Sven Gestegård Robertz
Browse files
java version2006 written, not tested
parent
7e0a91ce
Changes
4
Hide whitespace changes
Inline
Side-by-side
lib/java/Makefile
View file @
45b8e760
...
...
@@ -13,18 +13,26 @@ MODULES=LabCommDispatcher \
LabCommReader
\
WriterWrapper
all
:
labcomm.jar
all
:
labcomm.jar
labcomm2006.jar
labcomm.jar
:
gen/JAVAC
echo
$@
cd
gen
;
jar cf ../
$@
se/lth/control/labcomm/
*
.class
labcomm2006.jar
:
gen/JAVAC
echo
$@
cd
gen
;
jar cf ../
$@
se/lth/control/labcomm2006/
*
.class
gen
:
mkdir
gen
gen/JAVAC
:
$(MODULES:%=se/lth/control/labcomm/%.java) Makefile | gen
gen/JAVAC
:
$(MODULES:%=se/lth/control/labcomm/%.java)
$(MODULES:%=se/lth/control/labcomm2006/%.java)
Makefile | gen
javac
-d
gen
$(
filter
%.java,
$^
)
touch
$@
.PHONY
:
clean
clean
:
rm
-rf
labcomm.jar gen
rm
-rf
labcomm.jar gen labcomm2006.jar
lib/java/se/lth/control/labcomm2006/LabComm.java
View file @
45b8e760
...
...
@@ -27,6 +27,6 @@ public class LabComm {
/*
* Start of user declared types
*/
public
static
final
int
FIRST_USER_INDEX
=
0x
4
0
;
public
static
final
int
FIRST_USER_INDEX
=
0x
8
0
;
}
lib/java/se/lth/control/labcomm2006/LabCommDecoderChannel.java
View file @
45b8e760
...
...
@@ -134,19 +134,12 @@ public class LabCommDecoderChannel implements LabCommDecoder {
return
new
String
(
chars
);
}
/**
method for API harmonization with labcomm2013.
Labcomm2006 encodes lengths etc as 32 bit ints.
*/
public
int
decodePacked32
()
throws
IOException
{
long
res
=
0
;
byte
i
=
0
;
boolean
cont
=
true
;
do
{
byte
c
=
in
.
readByte
();
res
=
(
res
<<
7
)
|
(
c
&
0x7f
);
cont
=
(
c
&
0x80
)
!=
0
;
i
++;
}
while
(
cont
);
return
(
int
)
(
res
&
0xffffffff
);
return
in
.
readInt
();
}
}
lib/java/se/lth/control/labcomm2006/LabCommEncoderChannel.java
View file @
45b8e760
...
...
@@ -19,7 +19,7 @@ public class LabCommEncoderChannel implements LabCommEncoder {
data
=
new
DataOutputStream
(
bytes
);
registry
=
new
LabCommEncoderRegistry
();
if
(
emitVersion
)
{
throw
new
RuntimeError
(
"Labcomm 2006 does not support emitVersion"
);
throw
new
IllegalArgumentException
(
"Labcomm 2006 does not support emitVersion"
);
}
}
...
...
@@ -91,27 +91,17 @@ public class LabCommEncoderChannel implements LabCommEncoder {
public
void
encodeString
(
String
value
)
throws
IOException
{
data
.
writeShort
(
0
);
// HACK...
data
.
writeUTF
(
value
);
//kludge, to replace above hack with packed length
ByteArrayOutputStream
tmpb
=
new
ByteArrayOutputStream
();
DataOutputStream
tmps
=
new
DataOutputStream
(
tmpb
);
tmps
.
writeUTF
(
value
);
tmps
.
flush
();
byte
[]
tmp
=
tmpb
.
toByteArray
();
encodePacked32
(
tmp
.
length
-
2
);
for
(
int
i
=
2
;
i
<
tmp
.
length
;
i
++)
{
encodeByte
(
tmp
[
i
]);
}
}
/**
method for API harmonization with labcomm2013.
Labcomm2006 encodes lengths etc as 32 bit ints.
*/
public
inline
void
encodePacked32
(
long
value
)
throws
IOException
{
encodeInt
(
value
);
public
void
encodePacked32
(
long
value
)
throws
IOException
{
if
(
value
>
Integer
.
MAX_VALUE
)
{
throw
new
IllegalArgumentException
(
"Value too large, must fit in 32 bits"
);
}
encodeInt
((
int
)
value
);
}
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment