⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mainclass.java

📁 CardBus代码驱动等有用资料
💻 JAVA
字号:
/** * <p>Title: CardBus I/O Sample Application</p> * <p>Description: CardBus I/O Sample Application</p> * <p>Copyright: Copyright (c) 2005</p> * <p>Company: Mobile Satellite Services</p> * @author Poornima Sarvdevabhatla * @version 1.0 */import java.lang.RuntimeException;import cardbus.*;public class MainClass {  public static void main(String[] args) {    CardBus cardbus = new CardBus();    try {      cardbus.connect(0);    } catch (Exception e) {      e.printStackTrace();    }    int status = 0;    byte[] readRegisterValue = new byte[128];    status = cardbus.readMemoryFixAddr32bit(0, 128, readRegisterValue);    if (status > 0) {      for (int i = 0; i < status; i = i + 1) {        System.out.println("Read value # " + i +"(dec): " +          ((int)readRegisterValue[i]) + " (hex): " +          (Integer.toHexString((int)readRegisterValue[i])).toUpperCase());      }    }/*    byte[] valuesToBeWritten1 = new byte[]{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20};    int address1 = 0;    int noOfBytesToWrite1 = 19;    status = cardbus.writeMemFixAddr32bit(address1, noOfBytesToWrite1, valuesToBeWritten1);    if (status > 0) {      System.out.println("Successfully wrote " + status + " bytes.");      System.out.println("The following values were written:");      for (int i = 0; i < status; i = i + 1) {        System.out.println("Address " + (address1) +          ": Value written (dec): " + valuesToBeWritten1[i] +            "   (hex): " + zeroPadNumber(Integer.toHexString((int)valuesToBeWritten1[i]).toUpperCase(),2));      }    }    byte[] readRegisterValue1 = new byte[10];    status = cardbus.readIoFixAddr8bit(0, 10, readRegisterValue1);    if (status > 0) {      for (int i = 0; i < status; i = i + 1) {        System.out.println("Read value #" + (i) +" (dec): " +          ((int )readRegisterValue1[i]) + " (hex): " +            (Integer.toHexString((int)readRegisterValue1[i])).toUpperCase());      }    }    byte[] valuesToBeWritten = new byte[]{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20};    int address = 0;    int noOfBytesToWrite = 20;    status = cardbus.writeIoFixAddr8bit(address, noOfBytesToWrite, valuesToBeWritten);    if (status > 0) {      System.out.println("Successfully wrote " + status + " bytes.");      System.out.println("The following values were written:");      for (int i = 0; i < status; i = i + 1) {        System.out.println("Address " + (address) +          ": Value written (dec): " + valuesToBeWritten[i] +            "   (hex): " + zeroPadNumber(Integer.toHexString((int)valuesToBeWritten[i]).toUpperCase(),2));      }    }*/    cardbus.closeConnections();    System.out.println("Disposed a handle");  }/**************************************************************************************************************************************************************/  /** Zero-pads a <code>String[]</code>.   *   * @param StringToBePadded  the <code>String[]</code> to be zero-padded   * @param totalNoOfDigits  Total number of characters the return value should   * have. Must be greater or equal to the number of characters in the   * <code>StringToBePadded</code> input parameter.   * @return a zero-padded <code>String[]</code>   */  public static String zeroPadNumber(String StringToBePadded,                                              int totalNoOfDigits){    String returnString = StringToBePadded;    if (StringToBePadded.length() > totalNoOfDigits) {      return StringToBePadded.substring(0,totalNoOfDigits);    }    for (int i = 0; i < totalNoOfDigits-StringToBePadded.length() ; i = i + 1) {      returnString = "0" + returnString;    }    return returnString;  }/**************************************************************************************************************************************************************/}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -