Android IC读写器安卓小步伐 4

[复制链接]
发表于 2025-11-18 22:11:13 | 显示全部楼层 |阅读模式
读取T5557卡页面
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
  3.     xmlns:app="http://schemas.android.com/apk/res-auto"
  4.     xmlns:tools="http://schemas.android.com/tools"
  5.     android:layout_width="match_parent"
  6.     android:layout_height="match_parent"
  7.     android:padding="3dp"
  8.     tools:context=".T5557Activity">
  9.     <androidx.appcompat.widget.Toolbar
  10.         android:id="@+id/toolbar"
  11.         android:layout_width="match_parent"
  12.         android:layout_height="30dp"
  13.         android:background="?attr/colorPrimary"
  14.         app:navigationIcon="@drawable/baseline_arrow_back_ios_24"
  15.         app:titleTextColor="@color/white"
  16.         tools:ignore="MissingConstraints"
  17.         tools:layout_editor_absoluteY="0dp">
  18.         <TextView
  19.             android:id="@+id/TextViewlabelDispleft"
  20.             android:layout_width="wrap_content"
  21.             android:layout_height="match_parent"
  22.             android:text="返回"
  23.             android:textColor="@color/white"
  24.             android:textSize="16sp"
  25.             android:gravity="center"
  26.             android:onClick="retmain" />
  27.         <TextView
  28.             android:id="@+id/TextViewlabelDisp"
  29.             android:layout_width="match_parent"
  30.             android:layout_height="match_parent"
  31.             android:text="T5557卡测试页  "
  32.             android:textColor="@color/white"
  33.             android:textSize="16sp"
  34.             android:gravity="center_horizontal|right|center"
  35.             app:layout_constraintBottom_toBottomOf="parent"
  36.             app:layout_constraintEnd_toEndOf="parent"
  37.             app:layout_constraintStart_toStartOf="@+id/TextViewlabelDispleft"
  38.             app:layout_constraintTop_toTopOf="parent" />
  39.     </androidx.appcompat.widget.Toolbar>
  40.     <TextView
  41.         android:id="@+id/sample_text"
  42.         android:layout_width="fill_parent"
  43.         android:layout_height="150dp"
  44.         android:padding="3dp"
  45.         android:text="操作结果"
  46.         android:textSize="12sp"
  47.         android:background="@drawable/shape4border"
  48.         app:layout_constraintLeft_toLeftOf="parent"
  49.         app:layout_constraintBottom_toBottomOf="parent"
  50.         />
  51.     <ScrollView
  52.         android:id="@+id/scrollViewIC"
  53.         android:layout_width="fill_parent"
  54.         android:layout_height="0dp"
  55.         android:layout_marginBottom="5dp"
  56.         app:layout_constraintLeft_toLeftOf="parent"
  57.         app:layout_constraintTop_toBottomOf="@+id/toolbar"
  58.         app:layout_constraintBottom_toTopOf="@+id/sample_text"
  59.         android:scrollbars="horizontal"
  60.         >
  61.         <androidx.constraintlayout.widget.ConstraintLayout
  62.             android:layout_width="match_parent"
  63.             android:layout_height="wrap_content"
  64.             android:padding="3dp" >
  65.             <CheckBox
  66.                 android:id="@+id/chkPwdT5557"
  67.                 android:layout_width="wrap_content"
  68.                 android:layout_height="30dp"
  69.                 android:layout_marginLeft="2dp"
  70.                 android:textSize="12sp"
  71.                 android:checked="false"
  72.                 android:text="带密码操作"
  73.                 app:layout_constraintLeft_toLeftOf="parent"
  74.                 app:layout_constraintTop_toTopOf="parent"/>
  75.             <EditText
  76.                 android:id="@+id/editTextPwdT5557"
  77.                 android:layout_width="80dp"
  78.                 android:layout_height="wrap_content"
  79.                 android:layout_marginLeft="10dp"
  80.                 android:background="@drawable/shape4border"
  81.                 android:digits="0123456789ABCDEFabcdef"
  82.                 android:gravity="center"
  83.                 android:inputType="textCapCharacters"
  84.                 android:maxLength="8"
  85.                 android:maxLines="1"
  86.                 android:text="00000000"
  87.                 android:textSize="14sp"
  88.                 app:layout_constraintBottom_toBottomOf="@+id/chkPwdT5557"
  89.                 app:layout_constraintLeft_toRightOf="@+id/chkPwdT5557"
  90.                 app:layout_constraintTop_toTopOf="@+id/chkPwdT5557"
  91.                 />
  92.             <TextView
  93.                 android:layout_width="wrap_content"
  94.                 android:layout_height="wrap_content"
  95.                 android:text="(十六进制)"
  96.                 android:textSize="12sp"
  97.                 android:layout_marginLeft="10dp"
  98.                 app:layout_constraintLeft_toRightOf="@+id/editTextPwdT5557"
  99.                 app:layout_constraintTop_toTopOf="@+id/chkPwdT5557"
  100.                 app:layout_constraintBottom_toBottomOf="@+id/chkPwdT5557"/>
  101.             <CheckBox
  102.                 android:id="@+id/chkUidNeedT5557"
  103.                 android:layout_width="wrap_content"
  104.                 android:layout_height="30dp"
  105.                 android:layout_marginLeft="2dp"
  106.                 android:textSize="12sp"
  107.                 android:checked="false"
  108.                 android:text="仅操作指定卡号的卡"
  109.                 app:layout_constraintLeft_toLeftOf="parent"
  110.                 app:layout_constraintTop_toBottomOf="@+id/chkPwdT5557"/>
  111.             <EditText
  112.                 android:id="@+id/editTextUidT5557"
  113.                 android:layout_width="110dp"
  114.                 android:layout_height="wrap_content"
  115.                 android:layout_marginLeft="10dp"
  116.                 android:background="@drawable/shape4border"
  117.                 android:digits="0123456789ABCDEFabcdef"
  118.                 android:gravity="center"
  119.                 android:inputType="textCapCharacters"
  120.                 android:maxLength="12"
  121.                 android:maxLines="1"
  122.                 android:text="000000000000"
  123.                 android:textSize="14sp"
  124.                 app:layout_constraintBottom_toBottomOf="@+id/chkUidNeedT5557"
  125.                 app:layout_constraintLeft_toRightOf="@+id/chkUidNeedT5557"
  126.                 app:layout_constraintTop_toTopOf="@+id/chkUidNeedT5557" />
  127.             <TextView
  128.                 android:id="@+id/TextViewlabel0"
  129.                 android:layout_width="wrap_content"
  130.                 android:layout_height="wrap_content"
  131.                 android:text="返回数据:"
  132.                 android:textSize="12sp"
  133.                 app:layout_constraintBottom_toTopOf="@+id/TextViewRetDataT5557"
  134.                 app:layout_constraintLeft_toLeftOf="parent"
  135.                 app:layout_constraintTop_toBottomOf="@+id/chkUidNeedT5557" />
  136.             <TextView
  137.                 android:id="@+id/TextViewRetDataT5557"
  138.                 android:layout_width="fill_parent"
  139.                 android:layout_height="wrap_content"
  140.                 android:padding="3dp"
  141.                 android:text=""
  142.                 android:textSize="12sp"
  143.                 android:background="@drawable/shape4border"
  144.                 app:layout_constraintLeft_toLeftOf="parent"
  145.                 app:layout_constraintTop_toBottomOf="@+id/TextViewlabel0"
  146.                 />
  147.             <Button
  148.                 android:id="@+id/btnRetDataClrT5557"
  149.                 android:layout_width="wrap_content"
  150.                 android:layout_height="40dp"
  151.                 android:onClick="textclear5557"
  152.                 android:text="清空数据"
  153.                 android:textSize="11sp"
  154.                 app:layout_constraintBottom_toTopOf="@+id/TextViewRetDataT5557"
  155.                 app:layout_constraintRight_toRightOf="parent" />
  156.             <Button
  157.                 android:id="@+id/btnPwdChangeT5557"
  158.                 android:layout_width="wrap_content"
  159.                 android:layout_height="40dp"
  160.                 android:onClick="changepwd5557"
  161.                 android:text="修改卡密码"
  162.                 android:textSize="11sp"
  163.                 app:layout_constraintRight_toRightOf="parent"
  164.                 app:layout_constraintTop_toBottomOf="@+id/TextViewRetDataT5557" />
  165.             <TextView
  166.                 android:id="@+id/TextViewlabel1"
  167.                 android:layout_width="wrap_content"
  168.                 android:layout_height="wrap_content"
  169.                 android:text="新密码:"
  170.                 android:textSize="12sp"
  171.                 app:layout_constraintLeft_toLeftOf="parent"
  172.                 app:layout_constraintTop_toTopOf="@+id/btnPwdChangeT5557"
  173.                 app:layout_constraintBottom_toBottomOf="@+id/btnPwdChangeT5557"
  174.                 />
  175.             <EditText
  176.                 android:id="@+id/editTextPwdNewT5557"
  177.                 android:layout_width="80dp"
  178.                 android:layout_height="wrap_content"
  179.                 android:layout_marginLeft="10dp"
  180.                 android:background="@drawable/shape4border"
  181.                 android:digits="0123456789ABCDEFabcdef"
  182.                 android:gravity="center"
  183.                 android:inputType="textCapCharacters"
  184.                 android:maxLength="8"
  185.                 android:maxLines="1"
  186.                 android:text="00000000"
  187.                 android:textSize="14sp"
  188.                 app:layout_constraintBottom_toBottomOf="@+id/btnPwdChangeT5557"
  189.                 app:layout_constraintLeft_toRightOf="@+id/TextViewlabel1"
  190.                 app:layout_constraintTop_toTopOf="@+id/btnPwdChangeT5557" />
  191.             <TextView
  192.                 android:layout_width="wrap_content"
  193.                 android:layout_height="wrap_content"
  194.                 android:text="(十六进制)"
  195.                 android:textSize="12sp"
  196.                 android:layout_marginLeft="10dp"
  197.                 app:layout_constraintLeft_toRightOf="@+id/editTextPwdNewT5557"
  198.                 app:layout_constraintTop_toTopOf="@+id/editTextPwdNewT5557"
  199.                 app:layout_constraintBottom_toBottomOf="@+id/editTextPwdNewT5557"/>
  200.             <TextView
  201.                 android:id="@+id/TextViewlabel2"
  202.                 android:layout_width="wrap_content"
  203.                 android:layout_height="wrap_content"
  204.                 android:text="第0页:"
  205.                 android:textSize="12sp"
  206.                 app:layout_constraintLeft_toLeftOf="parent"
  207.                 app:layout_constraintTop_toTopOf="@+id/chkB0T5557"
  208.                 app:layout_constraintBottom_toBottomOf="@+id/chkB0T5557"
  209.                 />
  210.             <CheckBox
  211.                 android:id="@+id/chkB0T5557"
  212.                 android:layout_width="wrap_content"
  213.                 android:layout_height="30dp"
  214.                 android:layout_marginLeft="2dp"
  215.                 android:textSize="11sp"
  216.                 android:checked="false"
  217.                 android:text="块0"
  218.                 app:layout_constraintLeft_toRightOf="@+id/TextViewlabel2"
  219.                 app:layout_constraintTop_toBottomOf="@+id/btnPwdChangeT5557"/>
  220.             <CheckBox
  221.                 android:id="@+id/chkB1T5557"
  222.                 android:layout_width="wrap_content"
  223.                 android:layout_height="30dp"
  224.                 android:layout_marginLeft="2dp"
  225.                 android:textSize="11sp"
  226.                 android:checked="false"
  227.                 android:text="块1"
  228.                 app:layout_constraintLeft_toRightOf="@+id/chkB0T5557"
  229.                 app:layout_constraintBottom_toBottomOf="@+id/chkB0T5557"/>
  230.             <CheckBox
  231.                 android:id="@+id/chkB2T5557"
  232.                 android:layout_width="wrap_content"
  233.                 android:layout_height="30dp"
  234.                 android:layout_marginLeft="2dp"
  235.                 android:textSize="11sp"
  236.                 android:checked="false"
  237.                 android:text="块2"
  238.                 app:layout_constraintLeft_toRightOf="@+id/chkB1T5557"
  239.                 app:layout_constraintBottom_toBottomOf="@+id/chkB0T5557"/>
  240.             <CheckBox
  241.                 android:id="@+id/chkB3T5557"
  242.                 android:layout_width="wrap_content"
  243.                 android:layout_height="30dp"
  244.                 android:layout_marginLeft="2dp"
  245.                 android:textSize="11sp"
  246.                 android:checked="false"
  247.                 android:text="块3"
  248.                 app:layout_constraintLeft_toRightOf="@+id/chkB2T5557"
  249.                 app:layout_constraintBottom_toBottomOf="@+id/chkB0T5557"/>
  250.             <CheckBox
  251.                 android:id="@+id/chkB4T5557"
  252.                 android:layout_width="wrap_content"
  253.                 android:layout_height="30dp"
  254.                 android:layout_marginLeft="2dp"
  255.                 android:textSize="12sp"
  256.                 android:checked="false"
  257.                 android:text="块4"
  258.                 app:layout_constraintLeft_toRightOf="@+id/chkB3T5557"
  259.                 app:layout_constraintBottom_toBottomOf="@+id/chkB0T5557"/>
  260.             <CheckBox
  261.                 android:id="@+id/chkB5T5557"
  262.                 android:layout_width="wrap_content"
  263.                 android:layout_height="30dp"
  264.                 android:layout_marginLeft="2dp"
  265.                 android:textSize="12sp"
  266.                 android:checked="false"
  267.                 android:text="块5"
  268.                 app:layout_constraintLeft_toRightOf="@+id/chkB4T5557"
  269.                 app:layout_constraintBottom_toBottomOf="@+id/chkB0T5557"/>
  270.             <CheckBox
  271.                 android:id="@+id/chkB6T5557"
  272.                 android:layout_width="wrap_content"
  273.                 android:layout_height="30dp"
  274.                 android:layout_marginLeft="2dp"
  275.                 android:checked="false"
  276.                 android:text="块6"
  277.                 android:textSize="11sp"
  278.                 app:layout_constraintLeft_toLeftOf="parent"
  279.                 app:layout_constraintTop_toBottomOf="@+id/chkB0T5557" />
  280.             <CheckBox
  281.                 android:id="@+id/chkB7T5557"
  282.                 android:layout_width="wrap_content"
  283.                 android:layout_height="30dp"
  284.                 android:layout_marginLeft="2dp"
  285.                 android:textSize="12sp"
  286.                 android:checked="false"
  287.                 android:text="块7"
  288.                 app:layout_constraintLeft_toRightOf="@+id/chkB6T5557"
  289.                 app:layout_constraintBottom_toBottomOf="@+id/chkB6T5557"/>
  290.             <TextView
  291.                 android:id="@+id/TextViewlabel3"
  292.                 android:layout_width="wrap_content"
  293.                 android:layout_height="wrap_content"
  294.                 android:text="第1页:"
  295.                 android:textSize="12sp"
  296.                 android:layout_marginLeft="20dp"
  297.                 app:layout_constraintLeft_toRightOf="@+id/chkB7T5557"
  298.                 app:layout_constraintTop_toTopOf="@+id/chkB7T5557"
  299.                 app:layout_constraintBottom_toBottomOf="@+id/chkB7T5557"
  300.                 />
  301.             <CheckBox
  302.                 android:id="@+id/chkB11T5557"
  303.                 android:layout_width="wrap_content"
  304.                 android:layout_height="30dp"
  305.                 android:checked="false"
  306.                 android:text="块1"
  307.                 android:textSize="11sp"
  308.                 app:layout_constraintBottom_toBottomOf="@+id/chkB7T5557"
  309.                 app:layout_constraintLeft_toRightOf="@+id/TextViewlabel3" />
  310.             <CheckBox
  311.                 android:id="@+id/chkB12T5557"
  312.                 android:layout_width="wrap_content"
  313.                 android:layout_height="30dp"
  314.                 android:layout_marginLeft="2dp"
  315.                 android:checked="false"
  316.                 android:text="块2"
  317.                 android:textSize="11sp"
  318.                 app:layout_constraintBottom_toBottomOf="@+id/chkB7T5557"
  319.                 app:layout_constraintLeft_toRightOf="@+id/chkB11T5557" />
  320.             <CheckBox
  321.                 android:id="@+id/chkB13T5557"
  322.                 android:layout_width="wrap_content"
  323.                 android:layout_height="30dp"
  324.                 android:layout_marginLeft="2dp"
  325.                 android:checked="false"
  326.                 android:text="块3"
  327.                 android:textSize="11sp"
  328.                 app:layout_constraintBottom_toBottomOf="@+id/chkB7T5557"
  329.                 app:layout_constraintLeft_toRightOf="@+id/chkB12T5557" />
  330.             <CheckBox
  331.                 android:id="@+id/chkB14T5557"
  332.                 android:layout_width="wrap_content"
  333.                 android:layout_height="30dp"
  334.                 android:layout_marginLeft="2dp"
  335.                 android:checked="false"
  336.                 android:text="块4"
  337.                 android:textSize="11sp"
  338.                 app:layout_constraintBottom_toBottomOf="@+id/chkB7T5557"
  339.                 app:layout_constraintLeft_toRightOf="@+id/chkB13T5557" />
  340.             <Button
  341.                 android:id="@+id/btnReadT5557"
  342.                 android:layout_width="wrap_content"
  343.                 android:layout_height="40dp"
  344.                 android:layout_marginRight="20dp"
  345.                 android:onClick="read5557"
  346.                 android:text="读卡"
  347.                 android:textSize="11sp"
  348.                 app:layout_constraintRight_toLeftOf="@+id/btnWriteT5557"
  349.                 app:layout_constraintTop_toBottomOf="@+id/chkB7T5557" />
  350.             <Button
  351.                 android:id="@+id/btnWriteT5557"
  352.                 android:layout_width="wrap_content"
  353.                 android:layout_height="40dp"
  354.                 android:onClick="write5557"
  355.                 android:text="写卡"
  356.                 android:textSize="11sp"
  357.                 app:layout_constraintRight_toRightOf="parent"
  358.                 app:layout_constraintTop_toBottomOf="@+id/chkB7T5557" />
  359.             <TextView
  360.                 android:id="@+id/TextViewlabel4"
  361.                 android:layout_width="wrap_content"
  362.                 android:layout_height="wrap_content"
  363.                 android:text="写入数据:"
  364.                 android:textSize="12sp"
  365.                 app:layout_constraintBottom_toBottomOf="@+id/btnReadT5557"
  366.                 app:layout_constraintLeft_toLeftOf="parent" />
  367.             <EditText
  368.                 android:id="@+id/editTextDataT5557"
  369.                 android:layout_width="0dp"
  370.                 android:layout_height="40dp"
  371.                 android:background="@drawable/shape4border"
  372.                 android:digits="0123456789ABCDEFabcdef"
  373.                 android:gravity="left"
  374.                 android:inputType="textCapCharacters"
  375.                 android:maxLength="128"
  376.                 android:text="11111111"
  377.                 android:padding="3dp"
  378.                 android:textSize="12sp"
  379.                 app:layout_constraintLeft_toLeftOf="@+id/TextViewRetDataT5557"
  380.                 app:layout_constraintRight_toRightOf="@+id/TextViewRetDataT5557"
  381.                 app:layout_constraintTop_toBottomOf="@+id/btnWriteT5557" />
  382.             <TextView
  383.                 android:id="@+id/TextViewlabel5"
  384.                 android:layout_width="wrap_content"
  385.                 android:layout_height="wrap_content"
  386.                 android:text="配置区位于第0页第0块:\ne5550兼容模式,主控键值默认(不等于6及不等于9),波特率RF/32,调制模式为\n曼彻斯特码,相位键控RF/2,自动发送最大块为1,卡片复位无延时\n如需改动以上值请联系我们 !"
  387.                 android:textSize="12sp"
  388.                 app:layout_constraintTop_toBottomOf="@+id/editTextDataT5557"
  389.                 app:layout_constraintLeft_toLeftOf="parent" />
  390.             <CheckBox
  391.                 android:id="@+id/chkAOR"
  392.                 android:layout_width="wrap_content"
  393.                 android:layout_height="30dp"
  394.                 android:layout_marginLeft="2dp"
  395.                 android:textSize="12sp"
  396.                 android:checked="false"
  397.                 android:text="AOR请求应答模式"
  398.                 android:onClick="updateset5557"
  399.                 app:layout_constraintLeft_toLeftOf="parent"
  400.                 app:layout_constraintTop_toBottomOf="@+id/TextViewlabel5"/>
  401.             <CheckBox
  402.                 android:id="@+id/chkFrameEnd"
  403.                 android:layout_width="wrap_content"
  404.                 android:layout_height="30dp"
  405.                 android:layout_marginLeft="2dp"
  406.                 android:textSize="12sp"
  407.                 android:checked="true"
  408.                 android:text="帧终结符"
  409.                 android:onClick="updateset5557"
  410.                 app:layout_constraintLeft_toRightOf="@+id/chkAOR"
  411.                 app:layout_constraintBottom_toBottomOf="@+id/chkAOR"/>
  412.             <CheckBox
  413.                 android:id="@+id/chkPwdSetT5557"
  414.                 android:layout_width="wrap_content"
  415.                 android:layout_height="30dp"
  416.                 android:layout_marginLeft="2dp"
  417.                 android:textSize="12sp"
  418.                 android:checked="false"
  419.                 android:text="启用密码读写功能,并设密码为"
  420.                 android:onClick="updateset5557"
  421.                 app:layout_constraintLeft_toLeftOf="parent"
  422.                 app:layout_constraintTop_toBottomOf="@+id/chkAOR"/>
  423.             <EditText
  424.                 android:id="@+id/editTextPwdSetT5557"
  425.                 android:layout_width="80dp"
  426.                 android:layout_height="wrap_content"
  427.                 android:layout_marginLeft="10dp"
  428.                 android:background="@drawable/shape4border"
  429.                 android:digits="0123456789ABCDEFabcdef"
  430.                 android:gravity="center"
  431.                 android:inputType="textCapCharacters"
  432.                 android:maxLength="8"
  433.                 android:maxLines="1"
  434.                 android:text="00000000"
  435.                 android:textSize="14sp"
  436.                 app:layout_constraintBottom_toBottomOf="@+id/chkPwdSetT5557"
  437.                 app:layout_constraintLeft_toRightOf="@+id/chkPwdSetT5557"
  438.                 app:layout_constraintTop_toTopOf="@+id/chkPwdSetT5557"
  439.                 />
  440.             <TextView
  441.                 android:layout_width="wrap_content"
  442.                 android:layout_height="wrap_content"
  443.                 android:text="(十六进制)"
  444.                 android:textSize="12sp"
  445.                 android:layout_marginLeft="10dp"
  446.                 app:layout_constraintLeft_toRightOf="@+id/editTextPwdSetT5557"
  447.                 app:layout_constraintTop_toTopOf="@+id/chkPwdSetT5557"
  448.                 app:layout_constraintBottom_toBottomOf="@+id/chkPwdSetT5557"/>
  449.             <TextView
  450.                 android:id="@+id/TextViewlabel22"
  451.                 android:layout_width="wrap_content"
  452.                 android:layout_height="wrap_content"
  453.                 android:text="配置值:"
  454.                 android:textSize="12sp"
  455.                 app:layout_constraintTop_toTopOf="@+id/editTextConfigWordT5557"
  456.                 app:layout_constraintBottom_toBottomOf="@+id/editTextConfigWordT5557"
  457.                 app:layout_constraintLeft_toLeftOf="parent" />
  458.             <EditText
  459.                 android:id="@+id/editTextConfigWordT5557"
  460.                 android:layout_width="68dp"
  461.                 android:layout_height="wrap_content"
  462.                 android:layout_marginTop="5dp"
  463.                 android:background="@drawable/shape4border"
  464.                 android:digits="0123456789ABCDEFabcdef"
  465.                 android:gravity="left"
  466.                 android:inputType="textCapCharacters"
  467.                 android:maxLength="8"
  468.                 android:text="00088028"
  469.                 android:paddingLeft="3dp"
  470.                 android:textSize="12sp"
  471.                 app:layout_constraintLeft_toRightOf="@+id/TextViewlabel22"
  472.                 app:layout_constraintTop_toBottomOf="@+id/chkPwdSetT5557"
  473.                 />
  474.             <TextView
  475.                 android:id="@+id/textView"
  476.                 android:layout_width="wrap_content"
  477.                 android:layout_height="wrap_content"
  478.                 android:layout_marginLeft="10dp"
  479.                 android:text="(十六进制)"
  480.                 android:textSize="12sp"
  481.                 app:layout_constraintBottom_toBottomOf="@+id/editTextConfigWordT5557"
  482.                 app:layout_constraintLeft_toRightOf="@+id/editTextConfigWordT5557"
  483.                 app:layout_constraintTop_toTopOf="@+id/editTextConfigWordT5557" />
  484.             <Button
  485.                 android:id="@+id/btnDefalutT5557"
  486.                 android:layout_width="wrap_content"
  487.                 android:layout_height="40dp"
  488.                 android:layout_marginRight="3dp"
  489.                 android:onClick="default5557"
  490.                 android:text="← 默认值"
  491.                 android:textSize="11sp"
  492.                 app:layout_constraintRight_toLeftOf="@+id/btnInitT5557"
  493.                 app:layout_constraintBottom_toBottomOf="@+id/btnInitT5557" />
  494.             <Button
  495.                 android:id="@+id/btnInitT5557"
  496.                 android:layout_width="wrap_content"
  497.                 android:layout_height="40dp"
  498.                 android:onClick="init5557"
  499.                 android:text="设定配置"
  500.                 android:textSize="12sp"
  501.                 app:layout_constraintRight_toRightOf="parent"
  502.                 app:layout_constraintTop_toTopOf="@+id/editTextConfigWordT5557" />
  503.             <Button
  504.                 android:id="@+id/btnT5557to4100"
  505.                 android:layout_width="wrap_content"
  506.                 android:layout_height="wrap_content"
  507.                 android:onClick="t5557to4100"
  508.                 android:text="t5557卡配置成ID卡"
  509.                 android:textSize="12sp"
  510.                 app:layout_constraintLeft_toLeftOf="parent"
  511.                 app:layout_constraintTop_toBottomOf="@+id/btnInitT5557"/>
  512.             <TextView
  513.                 android:id="@+id/TextViewlabel23"
  514.                 android:layout_width="wrap_content"
  515.                 android:layout_height="wrap_content"
  516.                 android:text="厂商编码"
  517.                 android:textSize="12sp"
  518.                 app:layout_constraintTop_toTopOf="@+id/btnT5557to4100"
  519.                 app:layout_constraintBottom_toBottomOf="@+id/btnT5557to4100"
  520.                 app:layout_constraintLeft_toRightOf="@+id/btnT5557to4100" />
  521.         </androidx.constraintlayout.widget.ConstraintLayout>
  522.     </ScrollView>
复制代码
代码如下:
  1. public class T5557Activity extends AppCompatActivity {
  2.     private TextView tv;
  3.     private byte NEEDSERIAL = 0x01;   //需要只对指定系列号的卡操作
  4.     private byte NEEDKEY = 0x02;      //需要用密码认证
  5.     private byte LOCKBIT = 0x04;      //锁定配置块或数据块,仅对   t5557_init,t5557_write ,t5557_changekey函数有效
  6.     private byte KEYENABLE = 0x08;    //启用本卡的密码功能
  7.     private byte RESETCARD = 0x10;    //操作成功后重启卡片
  8.     @Override
  9.     protected void onCreate(Bundle savedInstanceState) {
  10.         super.onCreate(savedInstanceState);
  11.         setContentView(R.layout.activity_t5557);
  12.         androidx.appcompat.widget.Toolbar toolbar=findViewById(R.id.toolbar);
  13.         setSupportActionBar(toolbar);
  14.         tv = findViewById(R.id.sample_text);
  15.         tv.setText("操作结果");
  16.     }
  17.     @Override
  18.     public boolean onOptionsItemSelected(MenuItem item) {
  19.         if(item.getItemId()==android.R.id.home){
  20.             finish();
  21.             return true;
  22.         }
  23.         return super.onOptionsItemSelected(item);
  24.     }
  25.     public void retmain(View view)
  26.     {
  27.         finish();
  28.     }
  29.     public void textclear5557(View view)
  30.     {
  31.         TextView tvls;
  32.         tvls = findViewById(R.id.TextViewRetDataT5557);
  33.         tvls.setText("");
  34.     }
  35.     public void default5557(View view)
  36.     {
  37.         EditText etls;
  38.         CheckBox cbls;
  39.         etls = findViewById(R.id.editTextConfigWordT5557);
  40.         etls.setText("00088028");
  41.         cbls = findViewById(R.id.chkAOR);//AOR请求应答模式
  42.         cbls.setChecked(false);
  43.         cbls = findViewById(R.id.chkFrameEnd);//帧终结符
  44.         cbls.setChecked(true);
  45.         cbls = findViewById(R.id.chkPwdSetT5557);//启用密码读写功能,并设密码为
  46.         cbls.setChecked(false);
  47.     }
  48.     public void updateset5557(View view)
  49.     {
  50.         CheckBox cbls;
  51.         CheckBox cbAOR;
  52.         CheckBox cbPWD;
  53.         EditText etls;
  54.         byte[] Configdata = new byte[4];//配置值
  55.         etls = findViewById(R.id.editTextConfigWordT5557);
  56.         String strls = etls.getText().toString().trim();
  57.         if(strls.length() < 8){
  58.             strls = "00088028";
  59.             Configdata[0] = 0x00;
  60.             Configdata[1] = 0x08;
  61.             Configdata[2] = (byte)0x80;
  62.             Configdata[3] = 0x28;
  63.         }
  64.         else {
  65.             for (byte i = 0; i < 4; i++) {
  66.                 Configdata[i] = (byte)Integer.parseInt(strls.substring(i * 2, i * 2 + 2),16);//只有用Integer.parseInt才能杜绝大于128时的错误
  67.             }
  68.         }
  69.         cbAOR = findViewById(R.id.chkAOR);//AOR请求应答模式
  70.         cbPWD = findViewById(R.id.chkPwdSetT5557);//启用密码读写功能,并设密码为
  71.         if(cbAOR.isChecked()) {
  72.             if(!cbPWD.isChecked()) {//密码没启用,AOR无效
  73.                 cbAOR.setChecked(false);
  74.                 Configdata[2] &= 0xfd;
  75.                 tv.setText("密码没启用,AOR无效");
  76.             }
  77.             else {
  78.                 Configdata[2] |= 0x02;
  79.             }
  80.         }
  81.         else {
  82.             Configdata[2] &= 0xfd;
  83.         }
  84.         cbls = findViewById(R.id.chkFrameEnd);//帧终结符
  85.         if(cbls.isChecked()) {
  86.             Configdata[3] |= 0x08;
  87.         }
  88.         else {
  89.             Configdata[3] &= 0xf7;
  90.         }
  91.         if(cbPWD.isChecked()) {
  92.             if ((Configdata[3] & 0xe0) > (6 * 32)) {//启用密码功能后,最大块不能为7
  93.                 Configdata[3] &= 0x1f;
  94.                 Configdata[3] |=(6 * 32);
  95.             }
  96.             Configdata[3] |= 0x10;//启用密码功能
  97.         }
  98.         else{
  99.             Configdata[3] &= 0xef;//取消密码功能
  100.             Configdata[2] &= 0xfd;
  101.             cbAOR.setChecked(false);
  102.         }
  103.         etls.setText(String.format("%02X%02X%02X%02X",Configdata[0],Configdata[1],Configdata[2],Configdata[3]));
  104.     }
  105.     public void changepwd5557(View view)
  106.     {
  107.         byte i;
  108.         byte j;
  109.         byte status;//存放返回值
  110.         byte myctrlword;//控制字
  111.         byte[] oldpicckey = new byte[4];//密码
  112.         byte[] mypiccserial = new byte[6];//卡序列号
  113.         byte[] newpicckey = new byte[4];//指定写哪一块
  114.         myctrlword = 0; //NEEDSERIAL:需要只对指定系列号的卡操作,NEEDKEY:需要用密码认证,LOCKBIT:锁定块,KEYENABLE:启用本卡的密码功能
  115.         String strls;
  116.         CheckBox cbls;
  117.         EditText etls;
  118.         cbls = findViewById(R.id.chkPwdT5557);
  119.         if(cbls.isChecked()) {//本次操作需要密码验证
  120.             etls = findViewById(R.id.editTextPwdT5557);
  121.             strls = etls.getText().toString().trim();
  122.             if(strls.length() < 8)
  123.             {
  124.                 tv.setText("旧密码长度不足8位");
  125.                 return;
  126.             }
  127.             for (i = 0; i < 4; i++) {
  128.                 oldpicckey[i] = (byte)Integer.parseInt(strls.substring(i*2,i*2+2),16);//只有用Integer.parseInt才能杜绝大于128时的错误
  129.             }
  130.             myctrlword += ouridr.NEEDKEY;
  131.         }
  132.         cbls = findViewById(R.id.chkUidNeedT5557);
  133.         if(cbls.isChecked()) {//仅操作指定卡号的卡
  134.             etls = findViewById(R.id.editTextUidT5557);
  135.             strls = etls.getText().toString().trim();
  136.             if(strls.length() < 12)
  137.             {
  138.                 tv.setText("卡号长度不足12位");
  139.                 return;
  140.             }
  141.             for (i = 0; i < 6; i++) {
  142.                 mypiccserial[i] = (byte)Integer.parseInt(strls.substring(i*2,i*2+2),16);//只有用Integer.parseInt才能杜绝大于128时的错误
  143.             }
  144.             myctrlword += ouridr.NEEDSERIAL;
  145.         }
  146.         etls = findViewById(R.id.editTextPwdNewT5557);
  147.         strls = etls.getText().toString().trim();
  148.         if(strls.length() < 8)
  149.         {
  150.             tv.setText("新密码长度不足8位!");
  151.             return;
  152.         }
  153.         for (i = 0; i < 4; i++) {
  154.             newpicckey[i] = (byte)Integer.parseInt(strls.substring(i*2,i*2+2),16);//只有用Integer.parseInt才能杜绝大于128时的错误
  155.         }
  156.         status = ouridr.t5557changekey(myctrlword,mypiccserial,oldpicckey,newpicckey);
  157.         if(status == 0)
  158.         {
  159.             strls = "卡号[";
  160.             strls += String.format("%02X%02X%02X%02X%02X%02X",mypiccserial[0],mypiccserial[1],mypiccserial[2],mypiccserial[3],mypiccserial[4],mypiccserial[5]);
  161.             strls += "]";
  162.             TextView tvls = findViewById(R.id.TextViewRetDataT5557);
  163.             tvls.setText(strls);
  164.             strls = "更改T5557卡密码成功";
  165.             ouridr.beep(38);
  166.         }
  167.         else {
  168.             strls=GetErrInf(status);
  169.         }
  170.         tv.setText(strls);
  171.     }
  172.     public void read5557(View view)
  173.     {
  174.         byte i;
  175.         byte status;//存放返回值
  176.         byte myctrlword;//控制字
  177.         byte[] oldpicckey = new byte[4];//密码
  178.         byte[] mypiccserial = new byte[6];//卡序列号
  179.         byte[] mypiccdata = new byte[64];//读卡数据缓冲:卡无线转输分频比、卡内容长度(字节数),及最多返回12块的数据
  180.         byte[] mypiccblockflag = new byte[2];//指定读哪一块
  181.         myctrlword = 0; //NEEDSERIAL:需要只对指定系列号的卡操作,NEEDKEY:需要用密码认证,LOCKBIT:锁定块,KEYENABLE:启用本卡的密码功能
  182.         String strls;
  183.         CheckBox cbls;
  184.         EditText etls;
  185.         cbls = findViewById(R.id.chkPwdT5557);
  186.         if(cbls.isChecked()) {//本次操作需要密码验证
  187.             etls = findViewById(R.id.editTextPwdT5557);
  188.             strls = etls.getText().toString().trim();
  189.             if(strls.length() < 8)
  190.             {
  191.                 tv.setText("密码长度不足8位");
  192.                 return;
  193.             }
  194.             for (i = 0; i < 4; i++) {
  195.                 oldpicckey[i] = (byte)Integer.parseInt(strls.substring(i*2,i*2+2),16);//只有用Integer.parseInt才能杜绝大于128时的错误
  196.             }
  197.             myctrlword += ouridr.NEEDKEY;
  198.         }
  199.         cbls = findViewById(R.id.chkUidNeedT5557);
  200.         if(cbls.isChecked()) {//仅操作指定卡号的卡
  201.             etls = findViewById(R.id.editTextUidT5557);
  202.             strls = etls.getText().toString().trim();
  203.             if(strls.length() < 12)
  204.             {
  205.                 tv.setText("卡号长度不足12位");
  206.                 return;
  207.             }
  208.             for (i = 0; i < 6; i++) {
  209.                 mypiccserial[i] = (byte)Integer.parseInt(strls.substring(i*2,i*2+2),16);//只有用Integer.parseInt才能杜绝大于128时的错误
  210.             }
  211.             myctrlword += ouridr.NEEDSERIAL;
  212.         }
  213.         //操作块标志
  214.         //第0页的块
  215.         mypiccblockflag[0] = 0;
  216.         cbls = findViewById(R.id.chkB0T5557);
  217.         if(cbls.isChecked()) {
  218.             mypiccblockflag[0] += 1;
  219.         }
  220.         cbls = findViewById(R.id.chkB1T5557);
  221.         if(cbls.isChecked()) {
  222.             mypiccblockflag[0] += 2;
  223.         }
  224.         cbls = findViewById(R.id.chkB2T5557);
  225.         if(cbls.isChecked()) {
  226.             mypiccblockflag[0] += 4;
  227.         }
  228.         cbls = findViewById(R.id.chkB3T5557);
  229.         if(cbls.isChecked()) {
  230.             mypiccblockflag[0] += 8;
  231.         }
  232.         cbls = findViewById(R.id.chkB4T5557);
  233.         if(cbls.isChecked()) {
  234.             mypiccblockflag[0] += 16;
  235.         }
  236.         cbls = findViewById(R.id.chkB5T5557);
  237.         if(cbls.isChecked()) {
  238.             mypiccblockflag[0] += 32;
  239.         }
  240.         cbls = findViewById(R.id.chkB6T5557);
  241.         if(cbls.isChecked()) {
  242.             mypiccblockflag[0] += 64;
  243.         }
  244.         cbls = findViewById(R.id.chkB7T5557);
  245.         if(cbls.isChecked()) {
  246.             mypiccblockflag[0] += 128;
  247.         }
  248.         //第1页
  249.         mypiccblockflag[1] = 0;
  250.         cbls = findViewById(R.id.chkB11T5557);
  251.         if(cbls.isChecked()) {
  252.             mypiccblockflag[1] += 2;
  253.         }
  254.         cbls = findViewById(R.id.chkB12T5557);
  255.         if(cbls.isChecked()) {
  256.             mypiccblockflag[1] += 4;
  257.         }
  258.         cbls = findViewById(R.id.chkB13T5557);
  259.         if(cbls.isChecked()) {
  260.             mypiccblockflag[1] += 8;
  261.         }
  262.         cbls = findViewById(R.id.chkB14T5557);
  263.         if(cbls.isChecked()) {
  264.             mypiccblockflag[1] += 16;
  265.         }
  266.         status = ouridr.t5557read(myctrlword,mypiccserial,oldpicckey,mypiccblockflag,mypiccdata);
  267.         if(status == 0)
  268.         {
  269.             strls = "卡无线转输分频比[" + Integer.toString(mypiccdata[0]) + "],卡号[";
  270.             strls += String.format("%02X%02X%02X%02X%02X%02X",mypiccserial[0],mypiccserial[1],mypiccserial[2],mypiccserial[3],mypiccserial[4],mypiccserial[5]);
  271.             strls += "],卡数据[";
  272.             for (i = 0; i < mypiccdata[1]; i++) {
  273.                 strls += String.format("%02X",mypiccdata[i+2]);
  274.             }
  275.             strls += "]";
  276.             TextView tvls = findViewById(R.id.TextViewRetDataT5557);
  277.             tvls.setText(strls);
  278.             strls = "读T5557卡成功";
  279.             ouridr.beep(38);
  280.         }
  281.         else {
  282.             strls=GetErrInf(status);
  283.         }
  284.         tv.setText(strls);
  285.     }
  286.     public void write5557(View view)
  287.     {
  288.         byte i;
  289.         byte j;
  290.         byte status;//存放返回值
  291.         byte myctrlword;//控制字
  292.         byte[] oldpicckey = new byte[4];//密码
  293.         byte[] mypiccserial = new byte[6];//卡序列号
  294.         byte[] mypiccdata = new byte[64];//写入数据缓冲:最多12块的数据
  295.         byte[] mypiccblockflag = new byte[2];//指定写哪一块
  296.         myctrlword = 0; //NEEDSERIAL:需要只对指定系列号的卡操作,NEEDKEY:需要用密码认证,LOCKBIT:锁定块,KEYENABLE:启用本卡的密码功能
  297.         String strls;
  298.         CheckBox cbls;
  299.         EditText etls;
  300.         cbls = findViewById(R.id.chkPwdT5557);
  301.         if(cbls.isChecked()) {//本次操作需要密码验证
  302.             etls = findViewById(R.id.editTextPwdT5557);
  303.             strls = etls.getText().toString().trim();
  304.             if(strls.length() < 8)
  305.             {
  306.                 tv.setText("密码长度不足8位");
  307.                 return;
  308.             }
  309.             for (i = 0; i < 4; i++) {
  310.                 oldpicckey[i] = (byte)Integer.parseInt(strls.substring(i*2,i*2+2),16);//只有用Integer.parseInt才能杜绝大于128时的错误
  311.             }
  312.             myctrlword += ouridr.NEEDKEY;
  313.         }
  314.         cbls = findViewById(R.id.chkUidNeedT5557);
  315.         if(cbls.isChecked()) {//仅操作指定卡号的卡
  316.             etls = findViewById(R.id.editTextUidT5557);
  317.             strls = etls.getText().toString().trim();
  318.             if(strls.length() < 12)
  319.             {
  320.                 tv.setText("卡号长度不足12位");
  321.                 return;
  322.             }
  323.             for (i = 0; i < 6; i++) {
  324.                 mypiccserial[i] = (byte)Integer.parseInt(strls.substring(i*2,i*2+2),16);//只有用Integer.parseInt才能杜绝大于128时的错误
  325.             }
  326.             myctrlword += ouridr.NEEDSERIAL;
  327.         }
  328.         //操作块标志
  329.         j = 0;
  330.         //第0页的块
  331.         mypiccblockflag[0] = 0;
  332.         cbls = findViewById(R.id.chkB0T5557);
  333.         if(cbls.isChecked()) {
  334.             mypiccblockflag[0] += 1;
  335.             j++;
  336.         }
  337.         cbls = findViewById(R.id.chkB1T5557);
  338.         if(cbls.isChecked()) {
  339.             mypiccblockflag[0] += 2;
  340.             j++;
  341.         }
  342.         cbls = findViewById(R.id.chkB2T5557);
  343.         if(cbls.isChecked()) {
  344.             mypiccblockflag[0] += 4;
  345.             j++;
  346.         }
  347.         cbls = findViewById(R.id.chkB3T5557);
  348.         if(cbls.isChecked()) {
  349.             mypiccblockflag[0] += 8;
  350.             j++;
  351.         }
  352.         cbls = findViewById(R.id.chkB4T5557);
  353.         if(cbls.isChecked()) {
  354.             mypiccblockflag[0] += 16;
  355.             j++;
  356.         }
  357.         cbls = findViewById(R.id.chkB5T5557);
  358.         if(cbls.isChecked()) {
  359.             mypiccblockflag[0] += 32;
  360.             j++;
  361.         }
  362.         cbls = findViewById(R.id.chkB6T5557);
  363.         if(cbls.isChecked()) {
  364.             mypiccblockflag[0] += 64;
  365.             j++;
  366.         }
  367.         cbls = findViewById(R.id.chkB7T5557);
  368.         if(cbls.isChecked()) {
  369.             mypiccblockflag[0] += 128;
  370.             j++;
  371.         }
  372.         //第1页
  373.         mypiccblockflag[1] = 0;
  374.         cbls = findViewById(R.id.chkB11T5557);
  375.         if(cbls.isChecked()) {
  376.             mypiccblockflag[1] += 2;
  377.             j++;
  378.         }
  379.         cbls = findViewById(R.id.chkB12T5557);
  380.         if(cbls.isChecked()) {
  381.             mypiccblockflag[1] += 4;
  382.             j++;
  383.         }
  384.         cbls = findViewById(R.id.chkB13T5557);
  385.         if(cbls.isChecked()) {
  386.             mypiccblockflag[1] += 8;
  387.             j++;
  388.         }
  389.         cbls = findViewById(R.id.chkB14T5557);
  390.         if(cbls.isChecked()) {
  391.             mypiccblockflag[1] += 16;
  392.             j++;
  393.         }
  394.         //写卡数据准备
  395.         if(j == 0)
  396.         {
  397.             tv.setText("请先选择需要写入的块");
  398.             return;
  399.         }
  400.         etls = findViewById(R.id.editTextDataT5557);
  401.         strls = etls.getText().toString().trim();
  402.         if(strls.length() < (j*8))
  403.         {
  404.             tv.setText("写入数据长度不足,请补足数据!");
  405.             return;
  406.         }
  407.         for (i = 0; i < (j*4); i++) {
  408.             mypiccdata[i] = (byte)Integer.parseInt(strls.substring(i*2,i*2+2),16);//只有用Integer.parseInt才能杜绝大于128时的错误
  409.         }
  410.         status = ouridr.t5557write(myctrlword,mypiccserial,oldpicckey,mypiccblockflag,mypiccdata);
  411.         if(status == 0) {
  412.             strls = "卡号[";
  413.             strls += String.format("%02X%02X%02X%02X%02X%02X", mypiccserial[0], mypiccserial[1], mypiccserial[2], mypiccserial[3], mypiccserial[4], mypiccserial[5]);
  414.             strls += "]";
  415.             TextView tvls = findViewById(R.id.TextViewRetDataT5557);
  416.             tvls.setText(strls);
  417.             strls = "写T5557卡成功";
  418.             ouridr.beep(38);
  419.         }else {
  420.             strls=GetErrInf(status);
  421.         }
  422.             tv.setText(strls);
  423.     }
  424.     public void init5557(View view)
  425.     {
  426.         byte i;
  427.         byte status;//存放返回值
  428.         byte myctrlword;//控制字
  429.         byte[] oldpicckey = new byte[4];//密码
  430.         byte[] mypiccserial = new byte[6];//卡序列号
  431.         byte[] mypiccdata = new byte[4];//写入数据缓冲
  432.         byte[] newpicckey = new byte[4];//指定写哪一块
  433.         myctrlword = 0; //NEEDSERIAL:需要只对指定系列号的卡操作,NEEDKEY:需要用密码认证,LOCKBIT:锁定块,KEYENABLE:启用本卡的密码功能
  434.         String strls;
  435.         CheckBox cbls;
  436.         EditText etls;
  437.         cbls = findViewById(R.id.chkPwdT5557);
  438.         if(cbls.isChecked()) {//本次操作需要密码验证
  439.             etls = findViewById(R.id.editTextPwdT5557);
  440.             strls = etls.getText().toString().trim();
  441.             if(strls.length() < 8)
  442.             {
  443.                 tv.setText("密码长度不足8位");
  444.                 return;
  445.             }
  446.             for (i = 0; i < 4; i++) {
  447.                 oldpicckey[i] = (byte)Integer.parseInt(strls.substring(i*2,i*2+2),16);//只有用Integer.parseInt才能杜绝大于128时的错误
  448.             }
  449.             myctrlword += ouridr.NEEDKEY;
  450.         }
  451.         cbls = findViewById(R.id.chkPwdSetT5557);
  452.         if(cbls.isChecked()) {//启用密码读写功能
  453.             etls = findViewById(R.id.editTextPwdSetT5557);
  454.             strls = etls.getText().toString().trim();
  455.             if(strls.length() < 8)
  456.             {
  457.                 tv.setText("新密码长度不足8位");
  458.                 return;
  459.             }
  460.             for (i = 0; i < 4; i++) {
  461.                 newpicckey[i] = (byte)Integer.parseInt(strls.substring(i*2,i*2+2),16);//只有用Integer.parseInt才能杜绝大于128时的错误
  462.             }
  463.             myctrlword += ouridr.KEYENABLE;
  464.         }
  465.         else {
  466.             newpicckey[0] = 0x00;
  467.             newpicckey[1] = 0x00;
  468.             newpicckey[2] = 0x00;
  469.             newpicckey[3] = 0x00;
  470.         }
  471.         cbls = findViewById(R.id.chkUidNeedT5557);
  472.         if(cbls.isChecked()) {//仅操作指定卡号的卡
  473.             etls = findViewById(R.id.editTextUidT5557);
  474.             strls = etls.getText().toString().trim();
  475.             if(strls.length() < 12)
  476.             {
  477.                 tv.setText("卡号长度不足12位");
  478.                 return;
  479.             }
  480.             for (i = 0; i < 6; i++) {
  481.                 mypiccserial[i] = (byte)Integer.parseInt(strls.substring(i*2,i*2+2),16);//只有用Integer.parseInt才能杜绝大于128时的错误
  482.             }
  483.             myctrlword += ouridr.NEEDSERIAL;
  484.         }
  485.         //配置值:
  486.         etls = findViewById(R.id.editTextConfigWordT5557);
  487.         strls = etls.getText().toString().trim();
  488.         if(strls.length() < 8)
  489.         {
  490.             tv.setText("配置值输入长度不足8位");
  491.             return;
  492.         }
  493.         for (i = 0; i < 4; i++) {
  494.             mypiccdata[i] = (byte)Integer.parseInt(strls.substring(i*2,i*2+2),16);//只有用Integer.parseInt才能杜绝大于128时的错误
  495.         }
  496.         status = ouridr.t5557init(myctrlword,mypiccserial,oldpicckey,mypiccdata,newpicckey);
  497.         if(status == 0) {
  498.             strls = "卡号[";
  499.             strls += String.format("%02X%02X%02X%02X%02X%02X",mypiccserial[0],mypiccserial[1],mypiccserial[2],mypiccserial[3],mypiccserial[4],mypiccserial[5]);
  500.             strls += "]";
  501.             TextView tvls = findViewById(R.id.TextViewRetDataT5557);
  502.             tvls.setText(strls);
  503.             strls = "配置T5557卡成功";
  504.             ouridr.beep(38);
  505.         }
  506.         else {
  507.             strls=GetErrInf(status);
  508.         }
  509.         tv.setText(strls);
  510.     }
  511.     public void t5557to4100(View view){
  512.         byte[] myuidbuf=new byte[7];
  513.         byte[] oldpicckey=new byte[4];
  514.         byte[] newpicckey=new byte[4];
  515.         byte[] mypiccserial=new byte[6];
  516.         byte myctrlword=RESETCARD;
  517.         myuidbuf[0]=47;
  518.         myuidbuf[1]=1;
  519.         myuidbuf[2]=2;
  520.         myuidbuf[3]=3;
  521.         myuidbuf[4]=4;
  522.         byte status=ouridr.t5557to4100(myctrlword,mypiccserial,oldpicckey,newpicckey,myuidbuf);
  523.         if (status==0){
  524.             ouridr.beep(38);
  525.             tv.setText("T5557卡配置成ID卡成功!");
  526.         }else{
  527.             tv.setText("错误代码:"+Integer.toString(status));
  528.         }
  529.     }
  530.     public static String GetErrInf(byte errcode) {
  531.         String dispstr="";
  532.         switch(errcode){
  533.             case 1:
  534.                 dispstr="错误代码:1,写入配置的值不正确,配置区或密码区可能已被锁定,请重新写入!";
  535.                 break;
  536.             case 2:
  537.                 dispstr="错误代码:2,本卡尚未开启密码功能,函数myctrlword中无需加入NEEDKEY!";
  538.                 break;
  539.             case 3:
  540.                 dispstr="错误代码:3,需要指定密码,函数myctrlword要加入NEEDKEY!";
  541.                 break;
  542.             case 5:
  543.                 dispstr="错误代码:5,密码错误!";
  544.                 break;
  545.             case 8:
  546.                 dispstr="错误代码:8,卡不在感应区 或 密码不正确,请重新拿开卡后再放到感应区!";
  547.                 break;
  548.             case 23:
  549.                 dispstr="错误代码:23,发卡器未连接!";
  550.                 break;
  551.             default:
  552.                 dispstr="未知错误,错误代码:"+Integer.toString(errcode);
  553.                 break;
  554.         }
  555.        return dispstr;
  556.     }
  557. }
复制代码
 


免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

×
回复

使用道具 举报

登录后关闭弹窗

登录参与点评抽奖  加入IT实名职场社区
去登录
快速回复 返回顶部 返回列表