Bonsoir,
J'utilise ce bout de code pour ecouter un port UDP
Les trames arrivent comme ceci
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 public static void updateBouton(){ //On crée un Worker générique, cette fois SwingWorker sw = new SwingWorker<String, String>(){ protected String doInBackground() throws Exception { String nees = null; while(true) { String NewsMsg = null; String TamponAIS; try { try (DatagramSocket ClientSoc = new DatagramSocket(6020)) { byte Receivebuff[]=new byte[1024]; //NewsMsg = null; DatagramPacket dp=new DatagramPacket(Receivebuff,Receivebuff.length); ClientSoc.receive(dp); NewsMsg = new String(dp.getData(),0,dp.getLength()); BufferedReader entree = new BufferedReader(new StringReader(NewsMsg)); TamponAIS = NewsMsg; ClientSoc.close(); Thread.sleep(50); if((TamponAIS.substring(0, 6).equals("!AIVDM"))&&(TamponAIS.length()>19)){ TrameAIS = TamponAIS; this.doInBackground(); // System.out.println("1"); // System.out.print(1 + "::" + TrameAIS); } else if((TamponAIS.substring(0, 6) != "$PNMLS") && (TamponAIS.substring(0, 6) != "!AIVDM")){ TrameAIS = TrameAIS + TamponAIS; System.out.print( TrameAIS); } } } catch(Exception ex) { ex.printStackTrace(); } return nees; } }
ce que je souhaiterai c'est de passer de!AIVDM,1,1,,B,1:182j003R0K3T4H>PdLsbI20
HC8,0*51
!AIVDM,1,1,
,A,13ccWT001s0Hss4HWKicLa<2080d,0*08
!AIVDM,1,1,,A,13chtv003
$PNMLS,30,20,3*52
!AIVDM,1,1,,A,1:182j003R0K2
$PNMLS,31,20,3*53
F04Sd,0*1E
$PNMLS,28,21,3*5A
2f:H>agttbHN0@8Q,0*05
à!AIVDM,1,1,,B,1:182j003R0K3T4H>PdLsbI20
HC8,0*51
.!AIVDM,1,1,,B,1:182j003R0K3T4H>PdLsbI20HC8,0*51
Tout en ignorant les trames commencant par"$PNMLS"
Voici mon resultat
je n'arrive pas a virer "$PNMLS"$PNMLS,33,19,3*5B
$PNMLS,34,19,3*5C
!AIVDM,1,1,,A,1:182j0vCQ0Jlp@HA5p=1JLN00S<,0*69
$PNMLS,33,19,3*5B
!AIVDM,1,1,,A,1:182j0vCQ0Jlp@HA5p=1JLN00S<,0*69
$PNMLS,33,19,3*5B
$PNMLS,33,19,3*5B
!AIVDM,1,1,,A,1:182j0vCQ0Jlp@HA5p=1JLN00S<,0*69
$PNMLS,33,19,3*5B
$PNMLS,33,19,3*5B
$PNMLS,33,19,3*5B
Partager