Completed

Corrigir Bug Java

Published on the February 19, 2014 in IT & Programming

About this project

Open

Preciso de um profissional java para corrigir um bug em um software java opensource. O bug consiste em corrigir o código de criação de um pacote de dados para o envio a um dispositivo, porém algo está acontecendo quando se passa um ID numérico inteiro convertido para hexadecimal que é interpretado pelo aparelho.

Abaixo o trecho de código a ser corrigido que pode ser visto também em http://pastebin.com/wJPpQsHD

if (type == MSG_GPS || type == MSG_GPS_LBS || type == MSG_GPS_LBS_STATUS || type == MSG_GPS_PHONE) {         
            try {
                Command cmd = getDataManager().getCommandById(deviceId);
                if ((cmd.getCommand() != null) && (!cmd.getCommand().equals(""))) {
                   
                    String strcmd = cmd.getCommand().trim();
                    ChannelBuffer bufcmd = ChannelBuffers.directBuffer(100);

                    bufcmd.writeByte(0x78);
                    bufcmd.writeByte(0x78); //Start Bit
                    bufcmd.writeByte((5 + strcmd.length())); //Packet length
                    bufcmd.writeByte(0x80); //Protocol Number
                    bufcmd.writeByte((4 + strcmd.length())); //Length of Command                   
                       
                   
                    bufcmd.writeByte(0x01); // Server Flag Bit / inicio
                    bufcmd.writeByte(0x02);
                    bufcmd.writeByte(0x03);
                    bufcmd.writeByte(0x04); // Server Flag Bit / fim         

                    bufcmd.writeBytes(ChannelBuffers.copiedBuffer(strcmd, CharsetUtil.US_ASCII)); // Content
                    bufcmd.writeShort(buf.readUnsignedShort()); //Information Serial Number   
                    bufcmd.writeShort(Crc.crc16Ccitt(bufcmd.toByteBuffer(2, 4))); //Error Check 
                    bufcmd.writeByte(0x0D);
                    bufcmd.writeByte(0x0A); //Stop Bit
                    channel.write(bufcmd);
                    Log.info("Sent Command: " + strcmd);
                }
            } catch (Exception error) {
                Log.warning("Error to sent command: " + error.toString());
            }
}


(...)

Onde existe o comentário Server Flag Bit é o inicio do problema em questão, deverá ser substituído pela representação em hexadecimal por um ID vindo de uma tabela, para preenchimento do campo "Server Flag Bit" (que tem tamanho de 4 bytes) de acordo com o layout anexo do pacote.

Category IT & Programming

Delivery term: February 20, 2014

Skills needed