Java port done by my friend ... under development ...
=====================================
Sokol wrote:
I successfully finished implementation of java Socket (as standart JAVA implementation does not support other types of addresses) and DeviceAttacher based on socket-can. Its done using native saablin.so lib which contains base C functions for attaching-detaching device, opening-closing can-socket, reading-writeing frames to the can-socket. This C lib is based on the socket-can API. Other part is done in JAVA from where this native functions are called.
Here is a little snippet how it looks so far (java code):
DeviceAttacher deviceAttacher = new DeviceAttacher("/dev/ttyUSB0");
try {
//attach device /dev/ttyUSB0 to the interface
deviceAttacher.attach();
// obtain interfaceName to which the device was attached (usualy slc0)
String interfaceName = deviceAttacher.getAttachedInterfaceName();
// create socket at specified can-interface
Socket socket = new Socket(interfaceName);
socket.connect();
//write can-frame to the socket - sending the SID beep frame
socket.write(new Frame(0x430, 0x8004000000000000L));
socket.close();
} finally{
deviceAttacher.detach();
}
I also create some Classes for managing SID and Buttons (not finished yet)
// listener method
public void onButton(ButtonEvent event) {
if (event.isSidSet()) {
sid.beep(); // beep once
} else if (event.isSidClr(){
sid.beep(2); // beep twice
}
// you can also handle multiple press at once - sid DOWN and UP buttons pressed at once
if ((event.pressedButtons & (SID_DOWN | SID_UP)) > 0) {
sid.beep(3);
}
}
Stay tuned more will come :)
Mato