View Single Post
Old 10-22-2006, 02:20 PM   #1
scotty1024
Banned
scotty1024 is no ebook tyro.scotty1024 is no ebook tyro.scotty1024 is no ebook tyro.scotty1024 is no ebook tyro.scotty1024 is no ebook tyro.scotty1024 is no ebook tyro.scotty1024 is no ebook tyro.scotty1024 is no ebook tyro.scotty1024 is no ebook tyro.scotty1024 is no ebook tyro.
 
Posts: 1,300
Karma: 1479
Join Date: Jul 2006
Location: Peoples Republic of Washington
Device: Reader / iPhone / Librie / Kindle
displayMgrClient protocol

OK, got this all figured out.

Port number is 50555.

Code:
root@ereader:/usr/bin# displayMgrClient -d 10.0.1.2

From: /10.0.1.3 length: 6 data: 21302c312c30 ascii: !0,1,0

root@ereader:/usr/bin# displayMgrClient -d 10.0.1.2 -t

From: /10.0.1.3 length: 21 data: 21312c312c302c342c3939362c3730302c31303230 ascii: !1,1,0,4,996,700,1020

root@ereader:/usr/bin# displayMgrClient -d 10.0.1.2 -p

From: /10.0.1.3 length: 22 data: 21312c312c302c3130302c3130302c3330302c333030 ascii: !1,1,0,100,100,300,300
From: /10.0.1.3 length: 22 data: 21312c312c302c3530302c3730302c3730302c393030 ascii: !1,1,0,500,700,700,900
Example server code:

Code:
import java.net.DatagramSocket;
import java.net.DatagramPacket;

public class Display {

    public static void main(String[] args)
        throws Exception
    {
        byte[] buf = new byte[256];
        DatagramSocket s = new DatagramSocket(50555);
        DatagramPacket p = new DatagramPacket(buf, 256);
        while (true) {
            s.receive(p);
            System.out.println("From: " + p.getAddress() + " length: " + p.getLength() + " data: " + toHexString(buf, p.getLength()) + " ascii: " + new String(buf, 0, p.getLength()));
        }
    }

    public static String toHexString(byte bytes[], int length) {
        StringBuffer retString = new StringBuffer();
        for (int i = 0; i < length; ++i) {
            retString.append(Integer.toHexString(0x0100 + (bytes[i] & 0x00FF)).substring(1));
        }
        return retString.toString();
    }
}
Example client code to refresh entire display from Wonka:

Code:
import java.net.DatagramSocket;
import java.net.DatagramPacket;
import java.net.InetAddress;

public class Client {

    public static final int DISPLAY_MGR_PORT = 50555;
    private static final byte[] ENTIRE_DISPLAY = "!0,1,0".getBytes();

    public static void main(String[] args)
        throws Exception
    {
        refreshEntireDisplay();
    }

    public static void refreshEntireDisplay()
        throws Exception
    {
        DatagramPacket p = new DatagramPacket(ENTIRE_DISPLAY,
                                              ENTIRE_DISPLAY.length,
                                              InetAddress.getLocalHost(),
                                              DISPLAY_MGR_PORT);
        DatagramSocket s = new DatagramSocket();
        s.send(p);
        s.close();
    }
}
Tested, works.

Now I just need to go find where to bury the code in Wonka's AWT implementation...

Last edited by scotty1024; 10-22-2006 at 02:40 PM. Reason: Added tested client code
scotty1024 is offline   Reply With Quote