File: TestTodos.java

package info (click to toggle)
pilot-link 0.12.5-dfsg-2
  • links: PTS
  • area: main
  • in suites: buster, stretch
  • size: 6,868 kB
  • ctags: 5,811
  • sloc: ansic: 53,153; sh: 10,459; java: 2,584; perl: 2,247; python: 1,044; makefile: 991; yacc: 662; cpp: 551; xml: 39
file content (104 lines) | stat: -rw-r--r-- 2,681 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
import java.io.File;

import org.gnu.pilotlink.PilotLink;
import org.gnu.pilotlink.PilotLinkException;
import org.gnu.pilotlink.Record;
import org.gnu.pilotlink.SysInfo;
import org.gnu.pilotlink.ToDoRecord;
import org.gnu.pilotlink.User;

/*
 *  Created on 15.10.2004
 *
 *  TODO To change the template for this generated file go to
 *  Window - Preferences - Java - Code Style - Code Templates
 */
/**
 *@author     stephan TODO To change the template for this generated type
 *      comment go to Window - Preferences - Java - Code Style - Code Templates
 *@created    5. Dezember 2004
 */
public class TestTodos {

	/**
	 *  The main program for the TestTodos class
	 *
	 *@param  args  The command line arguments
	 */
	public static void main(String[] args) {
		String port;
		test tst = new test();
		if (args.length == 0) {
			port = "/dev/usb/tts/1";
		} else {
			port = args[0];
		}
		File p = new File(port);
		System.out.println("looking for file " + port);
		if (!p.exists()) {
			System.out.println("File does not exist... USB? Waiting for port to appear");

			while (!p.exists()) {
				System.out.print(".");
				try {
					Thread.sleep(1000);
				} catch (Exception e) {}
			}
		}
		//System.out.println("Systemzeit: "+Long.toHexString(System.currentTimeMillis()/1000));
		PilotLink pl = null;
		try {
			pl = new PilotLink(port);
			if (!pl.isConnected()) {
				System.out.println("Something went wrong. Check output!");
				System.exit(1);
			}
		} catch (Exception e) {
			e.printStackTrace();
			System.exit(1);
		}
		try {
			User u = pl.getUserInfo();
			System.out.println("User: " + u.getName());
			System.out.println("Last Synchronization Date: " + u.getLastSyncDate());
		} catch (PilotLinkException e) {
			e.printStackTrace();
		}
		try {
			SysInfo si = pl.getSysInfo();
			System.out.println("Product ID: '" + si.getProdID() + "'");
			System.out.println("Rom Version: " + si.getRomVersion());
		} catch (PilotLinkException e) {
			e.printStackTrace();
		}

		try {
			int dbh = pl.openDB("ToDoDB");
			System.out.println("db opened!");
			System.out.println("Count: " + pl.getRecordCount(dbh));
			for (int i = 0; i < pl.getRecordCount(dbh); i++) {
				Record r = pl.getRecordByIndex(dbh, i);
				ToDoRecord tdr = new ToDoRecord(r);
				System.out.println("READ IN:");
				System.out.println(tdr);
				tst.hexdump(r.getBuffer());

				System.out.println("\nRE-PACKED:");
				tst.hexdump(tdr.getBuffer());
				System.out.println();
			}
		} catch (PilotLinkException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}
		try {
			pl.endSync();
		} catch (PilotLinkException e) {
			e.printStackTrace();
		}
		pl.close();

	}

}