//package bouboule;

import java.io.*;

public class Test2 {
	
	private static ES com1 = new ES("COM1", true);
	
	public Test2() {}
	
	public static void main(String[] args) {
		try {
			com1.ouvrir();
			System.out.print("Commande : ");
			char commande = (char)(Byte.decode(Lecture.lireString()).byteValue());
			System.out.print("Liste des donnees : ");
			String dataString = Lecture.lireString();
			String[] dataList = dataString.split("\\s");
			char[] charList = new char[dataList.length];
			for(int i=0; i<dataList.length; i++) {
				charList[i] = (char)(Byte.decode(dataList[i])).byteValue();
			}
			String s = commande + (new String(charList));
			com1.envoyer(s);
			System.out.println("Chaine envoyee : " + s);
			//Thread.sleep(1000);
			String s2 = com1.recevoir();
			System.out.println("Chaine recu : " + s2);
			for(int j=0; j<s2.length(); j++) {
				System.out.print("0x" + Controle.hexa(s2.charAt(j)) + " ");
			}
		} catch (Exception e) { System.err.println(e); }
		try {
				com1.fermer();
			} catch (IOException e) { System.err.println(e); }
	}

}