当前位置: 首页>>代码示例>>Java>>正文


Java HexDump类代码示例

本文整理汇总了Java中com.hoho.android.usbserial.util.HexDump的典型用法代码示例。如果您正苦于以下问题:Java HexDump类的具体用法?Java HexDump怎么用?Java HexDump使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


HexDump类属于com.hoho.android.usbserial.util包,在下文中一共展示了HexDump类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: sendRawMessageToCar

import com.hoho.android.usbserial.util.HexDump; //导入依赖的package包/类
private void sendRawMessageToCar(String text) {
    BmwIBusService.IBusRawPacket packet;
    try {
        packet = BmwIBusService.IBusRawPacket.createFromString(text);
    } catch (IllegalArgumentException ex) {
        Toast.makeText(SettingsActivity.this, "Error: " + ex.getMessage(),
                Toast.LENGTH_LONG).show();
        return;
    }

    if (mService != null) {
        Toast.makeText(SettingsActivity.this, "Sending message: "
                + HexDump.toHexString(packet.toByteArray()),
                Toast.LENGTH_LONG).show();
        mService.sendIBusMessage(packet);
    }
}
 
开发者ID:OpilkiInside,项目名称:bimdroid,代码行数:18,代码来源:SettingsActivity.java

示例2: sendString

import com.hoho.android.usbserial.util.HexDump; //导入依赖的package包/类
private void sendString(String out) {
    byte[] b = out.getBytes(Charset.forName("UTF-8"));

    // anny messge for arduino  goes to screen
    String sended;
    if (b[0] == '*') {
        sended = out;
    } else {
        // sending commands to Arduino only if it not starts with '*'
        sended = String.format(getString(R.string.send), b.length) + " \n";
        sended += HexDump.dumpHexString(b) + "\n\n";
        if (mSerialIoManager != null) {
            try {
                mSerialIoManager.writeAsync(b);
            } catch (IOException e) {
                Log.w(TAG, "send error: " + e.getMessage());
            }
        }
    }
    writeTerminal(sended, colorPhp);
}
 
开发者ID:msillano,项目名称:USBphpTunnel,代码行数:22,代码来源:SerialConsoleActivity.java

示例3: updateReceivedData

import com.hoho.android.usbserial.util.HexDump; //导入依赖的package包/类
private void updateReceivedData(byte[] data) {
        final String message;
// any message from arduino to screen
        if (data[0] == '*') {
            message = new String(data);
        } else {
            message = String.format(getString(R.string.read), data.length) + " \n"
                    + HexDump.dumpHexString(data) + "\n\n";
        }
        writeTerminal(message, colorArduino);
        // tunnelling from arduino to php only if it starts with '/'
        if (data.length > 1 && data[0] == '/') {
            String rx = new String(data);
// test           new HttpAsyncTask().execute("/testio/add.php?primo=7&secondo=6.8&terzo=14:02");
            new HttpAsyncTask().execute(rx.trim());
        }

    }
 
开发者ID:msillano,项目名称:USBphpTunnel,代码行数:19,代码来源:SerialConsoleActivity.java

示例4: updateReceivedData

import com.hoho.android.usbserial.util.HexDump; //导入依赖的package包/类
private void updateReceivedData(byte[] data) {
    final String message = "Read " + data.length + " bytes: \n" + HexDump.dumpHexString(data) + "\n\n";
    byte[] valBuf = new byte[16];
    int numBytesRead = data.length;
    // readcount = readcount + numBytesRead;
    int potcount=readcount + numBytesRead;
    if (potcount<14) {
        System.arraycopy(data, 0, readbuf, readcount, numBytesRead);
        readcount=readcount+numBytesRead;
    }
    if (potcount>14) {
        System.arraycopy(data, 0, readbuf, readcount, 14-readcount);
        valBuf=readbuf;
        System.arraycopy(data, 14-readcount, readbuf, 0, numBytesRead-(14-readcount));
        readcount=numBytesRead-(14-readcount);
        parseReceivedData(valBuf);
    }

    if (potcount==14) {
        System.arraycopy(data, 0, readbuf, readcount, numBytesRead);
        parseReceivedData(readbuf);
        readcount = 0;
        Arrays.fill(readbuf, (byte) 0);
    }

}
 
开发者ID:kost,项目名称:DroidMeter,代码行数:27,代码来源:SerialConsoleActivity.java

示例5: sendIBusMessage

import com.hoho.android.usbserial.util.HexDump; //导入依赖的package包/类
/**
 * Sends a IBus message
 *
 * @return {@code true} if message sent successfully otherwise returns {@code false}.
 */
public boolean sendIBusMessage(IBusRawPacket packet) {
    if (mSerialIoManager == null
            || mSerialIoManager.getState() != SerialInputOutputManager.State.RUNNING) {
        if (DEBUG) Log.w(TAG, "Attempt to send ODB message when serial IO manager is not running");
        return false;
    }

    if (DEBUG) Log.i(TAG, "Sending message to IBus: " + HexDump.toHexString(packet.toByteArray()));
    mSerialIoManager.writeAsync(packet.toByteArray());
    return true;
}
 
开发者ID:OpilkiInside,项目名称:bimdroid,代码行数:17,代码来源:BmwIBusService.java

示例6: addByte

import com.hoho.android.usbserial.util.HexDump; //导入依赖的package包/类
void addByte(byte b) {
    mBuffer[mCurrentIndex++] = b;

    if (mCurrentIndex == mSize) {
        mCurrentIndex = 0;
        if (DEBUG) Log.d(TAG, "IBUS RAW DATA: " + HexDump.toHexString(mBuffer));
    }
}
 
开发者ID:OpilkiInside,项目名称:bimdroid,代码行数:9,代码来源:BmwIBusService.java

示例7: toString

import com.hoho.android.usbserial.util.HexDump; //导入依赖的package包/类
@Override
public String toString() {
    return "Packet { source: 0x" + HexDump.toHexString(source)
            + ", packetLength: " + packetLength
            + ", destination: 0x" + HexDump.toHexString(destination)
            + ", payload: " + HexDump.toHexString(payload, 0, getPayloadLength())
            + " }";
}
 
开发者ID:OpilkiInside,项目名称:bimdroid,代码行数:9,代码来源:BmwIBusService.java

示例8: handleMessage

import com.hoho.android.usbserial.util.HexDump; //导入依赖的package包/类
@Override
        public void handleMessage(Message msg) {
            switch (msg.what) {
                case MESSAGE_REFRESH:
                    refreshDeviceList();
                    mHandler.sendEmptyMessageDelayed(MESSAGE_REFRESH, REFRESH_TIMEOUT_MILLIS);
// == added fortunnel app m.s.
                    if ((autoPortSelection > 0) && (countrf++ >= autoPortSelection)) {  // number of refresh before connection
                        for (int i = 0; i < mEntries.size(); i++) {
                            final UsbSerialDriver driver = mEntries.get(i).getDriver();
                            final String vendorId = HexDump.toHexString((short) driver.getDevice().getVendorId());
                            final String productId = HexDump.toHexString((short) driver.getDevice().getProductId());
                            if (vendorId.equals(arduinoVendorId) && productId.equals(arduinoProductId)) {
                                countrf = 0;
                                showConsoleActivity(mEntries.get(i));

                            }
                        }

                    }
// == end added
                    break;
                default:
                    super.handleMessage(msg);
                    break;
            }
        }
 
开发者ID:msillano,项目名称:USBphpTunnel,代码行数:28,代码来源:DeviceListActivity.java

示例9: parse_ri

import com.hoho.android.usbserial.util.HexDump; //导入依赖的package包/类
private void parse_ri(String l0)
   {
String l1 ="";
String l2 ="";
String l3 ="";

l1 = l0.replace("\n", " ");
l2 = l1.replace("\r", " ");
l3 = l2.replace("=", " ");	
//Toast.makeText(Client.client, HexDump.dumpHexString(t[0].getBytes()), Toast.LENGTH_SHORT).show();
Toast.makeText(Client.client, HexDump.dumpHexString(l0.getBytes()), Toast.LENGTH_SHORT).show();
   }
 
开发者ID:herjulf,项目名称:Read-Sensors,代码行数:13,代码来源:ConfWindow.java

示例10: onCreate

import com.hoho.android.usbserial.util.HexDump; //导入依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    mUsbManager = (UsbManager) getSystemService(Context.USB_SERVICE);
    mListView = (ListView) findViewById(R.id.deviceList);
    mProgressBar = (ProgressBar) findViewById(R.id.progressBar);
    mProgressBarTitle = (TextView) findViewById(R.id.progressBarTitle);

    mAdapter = new ArrayAdapter<UsbSerialPort>(this,
            android.R.layout.simple_expandable_list_item_2, mEntries) {
        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            final TwoLineListItem row;
            if (convertView == null){
                final LayoutInflater inflater =
                        (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                row = (TwoLineListItem) inflater.inflate(android.R.layout.simple_list_item_2, null);
            } else {
                row = (TwoLineListItem) convertView;
            }

            final UsbSerialPort port = mEntries.get(position);
            final UsbSerialDriver driver = port.getDriver();
            final UsbDevice device = driver.getDevice();

            final String title = String.format("Vendor %s Product %s",
                    HexDump.toHexString((short) device.getVendorId()),
                    HexDump.toHexString((short) device.getProductId()));
            row.getText1().setText(title);

            final String subtitle = driver.getClass().getSimpleName();
            row.getText2().setText(subtitle);

            return row;
        }

    };
    mListView.setAdapter(mAdapter);

    mListView.setOnItemClickListener(new ListView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            Log.d(TAG, "Pressed item " + position);
            if (position >= mEntries.size()) {
                Log.w(TAG, "Illegal position.");
                return;
            }

            final UsbSerialPort port = mEntries.get(position);
            showConsoleActivity(port);
        }
    });
}
 
开发者ID:kost,项目名称:DroidMeter,代码行数:56,代码来源:MainActivity.java

示例11: updateReceivedData

import com.hoho.android.usbserial.util.HexDump; //导入依赖的package包/类
private void updateReceivedData(byte[] data) {
    final String message = "Read " + data.length + " bytes: \n"
            + HexDump.dumpHexString(data) + "\n\n";
    mDumpTextView.append(message);
    mScrollView.smoothScrollTo(0, mDumpTextView.getBottom());
}
 
开发者ID:rodolfo3,项目名称:android-vusb-arduino,代码行数:7,代码来源:SerialConsoleActivity.java

示例12: onCreate

import com.hoho.android.usbserial.util.HexDump; //导入依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    mUsbManager = (UsbManager) getSystemService(Context.USB_SERVICE);
    mListView = (ListView) findViewById(R.id.deviceList);
    mProgressBar = (ProgressBar) findViewById(R.id.progressBar);
    mProgressBarTitle = (TextView) findViewById(R.id.progressBarTitle);

    mAdapter = new ArrayAdapter<UsbSerialPort>(this,
            android.R.layout.simple_expandable_list_item_2, mEntries) {
        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            final TwoLineListItem row;
            if (convertView == null){
                final LayoutInflater inflater =
                        (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                row = (TwoLineListItem) inflater.inflate(android.R.layout.simple_list_item_2, null);
            } else {
                row = (TwoLineListItem) convertView;
            }

            final UsbSerialPort port = mEntries.get(position);
            final UsbSerialDriver driver = port.getDriver();
            final UsbDevice device = driver.getDevice();

            final String title = String.format("Vendor %s Product %s",
                    HexDump.toHexString((short) device.getVendorId()),
                    HexDump.toHexString((short) device.getProductId()));
            row.getText1().setText(title);

            final String subtitle = driver.getClass().getSimpleName();
            row.getText2().setText(subtitle);

            return row;
        }

    };
    mListView.setAdapter(mAdapter);

    mListView.setOnItemClickListener(new ListView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            Log.d(TAG, "Pressed item " + position);
            if (position >= mEntries.size()) {
                Log.w(TAG, "Illegal position.");
                return;
            }

            final UsbSerialPort port = mEntries.get(position);
            showConsoleActivity(port);
        }
    });
}
 
开发者ID:rodolfo3,项目名称:android-vusb-arduino,代码行数:56,代码来源:DeviceListActivity.java


注:本文中的com.hoho.android.usbserial.util.HexDump类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。