Cadre Signaler ce document × Veuillez choisir une raison Droits d'auteur et autres atteintes à la propriété intellectuelle Par exemple, violation des droits d'auteur Violations de la vie privée Par exemple, la divulgation non autorisée de données à caractère personnel Contenu inapproprié Par exemple, contenu à caractère terroriste, protection des mineurs, etc. Annuler Suivant Vous serez redirigé × Lorsque vous cliquez sur "continuer", vous serez redirigé vers notre formulaire de rapport pour soumettre une demande de retrait Annuler Continuer 422 mots 2 pages Montre plus EcrireSurCom.java 1 import gnu.io.CommPortIdentifier; 8 9 public class EcrireSurCom { 10 static Enumeration portList; 11 static CommPortIdentifier portId; 12 static String messageString = "MORAD\t"; 13 static SerialPort serialPort; 14 static OutputStream outputStream; 15 static boolean outputBufferEmptyFlag = false; 16 static byte trameConnexion[] = new byte[4]; 17 static byte trameTension[] = new byte[3]; 18 static byte trameEnvoi[] = new byte[3]; 19 static byte trameDeconnexion[] = new byte[2]; 20 21 22 23 24 //byte[] m = new byte[7]; 25 //b[0] = (byte) (0xFF & (entier >> 8 * 0)); 26 27 // m[0] = (byte) (0xFF & (01110101)) ; 28 29 /** 30 * Method declaration 31 * 32 * 33 * @param args 34 * 35 * @see 36 */ 37 public static void main(String[] args) { 38 39 trameConnexion[0] = (byte) 0x61; 40 trameConnexion[0] = (byte) 0xf2; 41 trameConnexion[1] = (byte) 0x02; 42 trameConnexion[2] = (byte) 0x01; 43 trameConnexion[3] = (byte)((int)trameConnexion[0] ^ (int)trameConnexion[1] ^ (int)trameConnexion[2]); 44 System.out.println(ByteToHex(trameConnexion)); 45 trameTension[0] = (byte) 0x21; 46 trameTension[1] = (byte) 0x81; 47 trameTension[2] = (byte)((int)trameTension[0] ^ (int)trameTension[1]); 48 trameDeconnexion[0] = (byte)0x80; 49 trameDeconnexion[1] = (byte)0x80; 50 boolean portFound = false; 51 String defaultPort = "COM1"; 52 53 if (args.length > 0) { 54 defaultPort = args[0]; 55 } 56 57 portList = CommPortIdentifier.getPortIdentifiers(); 58 59 while (portList.hasMoreElements()) { 60 portId = (CommPortIdentifier) portList.nextElement(); 61 62 if (portId.getPortType() == CommPortIdentifier.PORT_SERIAL) { 63 64 if (portId.getName().equals(defaultPort)) { 65 System.out.println("Found port " + defaultPort); 66 67 portFound = true; 68 69 try { Page 1 EcrireSurCom.java 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 105 106 107 ; 108 th); 109 110 ength); 111 112 113 114 115 116 117 118 119 120 121 122 closing