@@ -0,0 +1,1528 @@
+/*%0D%0A * To change this license header, choose License Headers in Project Properties.%0D%0A * To change this template file, choose Tools %7C Templates%0D%0A * and open the template in the editor.%0D%0A */%0D%0Apackage ts.utility;%0D%0A%0D%0Aimport org.slf4j.Logger;%0D%0Aimport org.slf4j.LoggerFactory;%0D%0A%0D%0Aimport java.io.IOException;%0D%0Aimport java.io.InputStream;%0D%0Aimport java.util.ArrayList;%0D%0Aimport java.util.List;%0D%0Aimport java.util.logging.Level;%0D%0A%0D%0Aimport ts.mqttsn.MqttSnClient;%0D%0Aimport ts.mqttsn.XBeeAtClient;%0D%0A/**%0D%0A *%0D%0A * @author loki.chuang%0D%0A */%0D%0A%0D%0Apublic class SerialTool%0D%0A%7B%0D%0A    private static final Logger LOG = LoggerFactory.getLogger(MqttSnClient.class);%0D%0A    %0D%0A    public static byte%5B%5D readSerial(InputStream in ,long timeOut)%0D%0A    %7B%0D%0A        List%3CByte%3E recvArray = new ArrayList%3C%3E(1024);%0D%0A        long startTime = System.currentTimeMillis();%0D%0A        int temp;%0D%0A        while (System.currentTimeMillis() - startTime %3C timeOut)%0D%0A        %7B%0D%0A            try%0D%0A            %7B%0D%0A                temp = in.read();%0D%0A                if (temp %3E -1)%0D%0A                %7B%0D%0A                    recvArray.add((byte)temp);%0D%0A                %7D%0D%0A            %7D catch (IOException ex)%0D%0A            %7B%0D%0A                LOG.error(ex.toString());%0D%0A                //Logger.getLogger(XBeeAtClient.class.getName()).log(Level.SEVERE, null, ex);%0D%0A            %7D%0D%0A        %7D%0D%0A%0D%0A        byte%5B%5D array = new byte%5BrecvArray.size()%5D;%0D%0A        for (int i = 0; i %3C recvArray.size(); i++)%0D%0A        %7B%0D%0A            array%5Bi%5D = recvArray.get(i);%0D%0A        %7D%0D%0A%0D%0A        return array;%0D%0A    %7D%0D%0A%7D%0D%0A

Work for XBeeAtClient 20%