安卓Android Studio读写FM1208CPU卡源码

news2024/9/20 14:52:27

本示例使用的发卡器:https://item.taobao.com/item.htm?spm=a1z10.5-c-s.w4002-21818769070.11.6c46789elLwMzv&id=615391857885 

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:padding="3dp"
    tools:context=".CpuCardActivity">

    <androidx.appcompat.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="30dp"
        android:background="?attr/colorPrimary"
        app:navigationIcon="@drawable/baseline_arrow_back_ios_24"
        app:titleTextColor="@color/white"
        tools:ignore="MissingConstraints"
        tools:layout_editor_absoluteY="0dp">

        <TextView
            android:id="@+id/TextViewlabelDispleft"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:text="返回"
            android:textColor="@color/white"
            android:textSize="16sp"
            android:gravity="center"
            android:onClick="retmain" />

        <TextView
            android:id="@+id/TextViewlabelDisp"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:text="CPU卡测试页"
            android:textColor="@color/white"

            android:gravity="center_horizontal|bottom"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="@+id/TextViewlabelDispleft"
            app:layout_constraintTop_toTopOf="parent" />

    </androidx.appcompat.widget.Toolbar>


    <TextView
        android:id="@+id/sample_text"
        android:layout_width="fill_parent"
        android:layout_height="100dp"
        android:layout_marginLeft="2dp"
        android:layout_marginBottom="5dp"
        android:background="@drawable/shape4border"
        android:padding="3dp"
        android:text="操作结果"
        android:textSize="12sp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="parent" />

    <ScrollView
        android:id="@+id/scrollViewIC"
        android:layout_width="fill_parent"
        android:layout_height="0dp"
        android:layout_marginBottom="3dp"

        android:scrollbars="horizontal"
        app:layout_constraintBottom_toTopOf="@+id/sample_text"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/toolbar"
        app:layout_constraintVertical_bias="0.0">

        <androidx.constraintlayout.widget.ConstraintLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:padding="3dp">

            <Button
                android:id="@+id/requestcpucard"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginEnd="3dp"
                android:layout_marginRight="3dp"
                android:onClick="cpu_request"
                android:text="激活感应区内的CPU卡"
                android:textSize="11sp"
                app:layout_constraintLeft_toLeftOf="parent"
                app:layout_constraintTop_toTopOf="parent" />

            <TextView
                android:id="@+id/textView0"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginLeft="8dp"
                android:layout_marginTop="5dp"
                android:text="卡片UID:"
                android:textSize="12sp"
                app:layout_constraintLeft_toRightOf="@+id/requestcpucard"
                app:layout_constraintTop_toTopOf="@+id/requestcpucard" />

            <TextView
                android:id="@+id/textView10"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginLeft="8dp"
                android:text="每次卡片重新进入到感应区,都必须先激活!"
                android:textColor="#FF0000"
                android:textSize="11sp"
                app:layout_constraintBottom_toBottomOf="@+id/requestcpucard"
                app:layout_constraintLeft_toRightOf="@+id/requestcpucard" />


            <TextView
                android:id="@+id/textcarduid"
                android:layout_width="100dp"
                android:layout_height="wrap_content"
                android:layout_marginLeft="8dp"
                android:background="@drawable/shape4border"
                android:gravity="center"
                android:textSize="14sp"
                app:layout_constraintBottom_toBottomOf="@+id/textView0"
                app:layout_constraintLeft_toRightOf="@+id/textView0"
                app:layout_constraintTop_toTopOf="@+id/textView0" />

            <Button
                android:id="@+id/cpu_rsinit"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="8dp"
                android:onClick="cpu_rsinit"
                android:text="初始化CPU卡"
                android:textSize="11sp"
                app:layout_constraintLeft_toLeftOf="parent"
                app:layout_constraintTop_toBottomOf="@+id/requestcpucard" />

            <CheckBox
                android:id="@+id/checkcleckcard"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="选择先清空卡再初始化,本次分配空间:"
                android:textSize="11sp"
                app:layout_constraintLeft_toRightOf="@+id/cpu_rsinit"
                app:layout_constraintTop_toTopOf="@+id/cpu_rsinit" />

            <EditText
                android:id="@+id/textusespace"
                android:layout_width="40dp"
                android:layout_height="wrap_content"
                android:background="@drawable/shape4border"
                android:textColor="#FF0000"
                android:gravity="center"
                android:text="1024"
                android:textSize="12sp"
                app:layout_constraintBottom_toBottomOf="@+id/checkcleckcard"
                app:layout_constraintLeft_toRightOf="@+id/checkcleckcard"
                app:layout_constraintTop_toTopOf="@+id/checkcleckcard" />

            <TextView
                android:id="@+id/textView2"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="设置卡片32位16进制密钥:"
                android:textSize="12sp"
                app:layout_constraintLeft_toLeftOf="parent"
                app:layout_constraintTop_toBottomOf="@+id/cpu_rsinit" />

            <EditText
                android:id="@+id/cardkey"
                android:layout_width="235dp"
                android:layout_height="wrap_content"
                android:layout_marginLeft="4dp"
                android:background="@drawable/shape4border"
                android:digits="0123456789ABCDEFabcdef"
                android:gravity="center"
                android:inputType="textCapCharacters"
                android:maxLength="32"
                android:maxLines="1"
                android:text="FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
                android:textSize="12sp"
                app:layout_constraintBottom_toBottomOf="@+id/textView2"
                app:layout_constraintLeft_toRightOf="@+id/textView2"
                app:layout_constraintTop_toTopOf="@+id/cpu_rsinit"
                app:layout_constraintVertical_bias="0.96" />

            <Button
                android:id="@+id/butt_cpu_rseasyfileadd"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="8dp"
                android:onClick="cpu_rseasyfileadd"
                android:text="创建易写文件"
                android:textSize="11sp"
                app:layout_constraintLeft_toLeftOf="parent"
                app:layout_constraintTop_toBottomOf="@+id/textView2" />

            <Button
                android:id="@+id/butt_cpursfileadd"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:onClick="cpu_rsfileadd"
                android:text="创建标准文件"
                android:textSize="11sp"
                app:layout_constraintBottom_toBottomOf="@+id/butt_cpu_rseasyfileadd"
                app:layout_constraintLeft_toRightOf="@+id/butt_cpu_rseasyfileadd"
                app:layout_constraintTop_toTopOf="@+id/butt_cpu_rseasyfileadd" />

            <TextView
                android:id="@+id/textviewcreafile"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="请选择本次创建的文件号:"
                android:textSize="12sp"
                app:layout_constraintLeft_toLeftOf="parent"
                app:layout_constraintTop_toBottomOf="@+id/butt_cpu_rseasyfileadd" />

            <Spinner
                android:id="@+id/spin_SelCreatefilenum"
                android:layout_width="130dp"
                android:layout_height="wrap_content"
                android:layout_marginLeft="8dp"
                android:entries="@array/cpucardfile"
                android:textSize="11sp"
                app:layout_constraintBottom_toBottomOf="@+id/textviewcreafile"
                app:layout_constraintLeft_toRightOf="@+id/textviewcreafile"
                app:layout_constraintTop_toTopOf="@+id/textviewcreafile" />


            <TextView
                android:id="@+id/textView1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginLeft="8dp"
                android:text="文件大小:"
                android:textSize="11sp"
                app:layout_constraintBottom_toBottomOf="@+id/spin_SelCreatefilenum"
                app:layout_constraintLeft_toRightOf="@+id/spin_SelCreatefilenum"
                app:layout_constraintTop_toTopOf="@+id/spin_SelCreatefilenum" />

            <EditText
                android:id="@+id/textfileszie"
                android:layout_width="40dp"
                android:layout_height="wrap_content"
                android:layout_marginLeft="5dp"
                android:background="@drawable/shape4border"
                android:textColor="#FF0000"
                android:gravity="center"
                android:text="256"
                android:textSize="12sp"
                app:layout_constraintBottom_toBottomOf="@+id/textView1"
                app:layout_constraintLeft_toRightOf="@+id/textView1"
                app:layout_constraintTop_toTopOf="@+id/textView1" />

            <TextView
                android:id="@+id/textView3"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="5dp"
                android:text="文件32位16进制只读密钥:"
                android:textSize="12sp"
                app:layout_constraintLeft_toLeftOf="parent"
                app:layout_constraintTop_toBottomOf="@+id/textviewcreafile" />

            <EditText
                android:id="@+id/readkey"
                android:layout_width="235dp"
                android:layout_height="wrap_content"
                android:layout_marginLeft="8dp"
                android:background="@drawable/shape4border"
                android:digits="0123456789ABCDEFabcdef"
                android:gravity="center"
                android:inputType="textCapCharacters"
                android:maxLength="32"
                android:maxLines="1"
                android:text="FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
                android:textSize="12sp"
                app:layout_constraintBottom_toBottomOf="@+id/textView3"
                app:layout_constraintLeft_toRightOf="@+id/textView3" />

            <TextView
                android:id="@+id/textView4"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="5dp"
                android:text="文件32位16进制只读密钥:"
                android:textSize="12sp"
                app:layout_constraintLeft_toLeftOf="parent"
                app:layout_constraintTop_toBottomOf="@+id/textView3" />

            <EditText
                android:id="@+id/writekey"
                android:layout_width="235dp"
                android:layout_height="wrap_content"
                android:layout_marginLeft="8dp"
                android:background="@drawable/shape4border"
                android:digits="0123456789ABCDEFabcdef"
                android:gravity="center"
                android:inputType="textCapCharacters"
                android:maxLength="32"
                android:maxLines="1"
                android:text="FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
                android:textSize="12sp"
                app:layout_constraintBottom_toBottomOf="@+id/textView4"
                app:layout_constraintLeft_toRightOf="@+id/textView4" />

            <Button
                android:id="@+id/butt_changfilekey"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="8dp"
                android:onClick="cpu_rsfilekeychg"
                android:text="修改文件密钥"
                android:textSize="11sp"
                app:layout_constraintLeft_toLeftOf="parent"
                app:layout_constraintTop_toBottomOf="@+id/textView4" />

            <Spinner
                android:id="@+id/spin_Selchangkeyfile"
                android:layout_width="130dp"
                android:layout_height="wrap_content"
                android:entries="@array/cpucardfile"
                android:textSize="11sp"
                app:layout_constraintBottom_toBottomOf="@+id/butt_changfilekey"
                app:layout_constraintLeft_toRightOf="@+id/butt_changfilekey"
                app:layout_constraintTop_toTopOf="@+id/butt_changfilekey" />

            <TextView
                android:id="@+id/textviewchanekeyfile"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="请选择:"
                android:textSize="12sp"
                app:layout_constraintLeft_toLeftOf="parent"
                app:layout_constraintTop_toBottomOf="@+id/butt_changfilekey" />

            <Spinner
                android:id="@+id/spin_Selauthkey"
                android:layout_width="180dp"
                android:layout_height="wrap_content"
                android:entries="@array/cpucardauthkey"
                android:textSize="11sp"
                app:layout_constraintBottom_toBottomOf="@+id/textviewchanekeyfile"
                app:layout_constraintLeft_toRightOf="@+id/textviewchanekeyfile"
                app:layout_constraintTop_toTopOf="@+id/textviewchanekeyfile" />

            <Spinner
                android:id="@+id/spin_SelchangRWkey"
                android:layout_width="180dp"
                android:layout_height="wrap_content"
                android:entries="@array/cpucardchangkey"
                android:textSize="11sp"
                app:layout_constraintBottom_toBottomOf="@+id/spin_Selauthkey"
                app:layout_constraintLeft_toRightOf="@+id/spin_Selauthkey"
                app:layout_constraintTop_toTopOf="@+id/spin_Selauthkey" />

            <TextView
                android:id="@+id/textView5"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="5dp"
                android:text="32位16进制认证密钥:"
                android:textSize="12sp"
                app:layout_constraintLeft_toLeftOf="parent"
                app:layout_constraintTop_toBottomOf="@+id/spin_Selauthkey" />

            <EditText
                android:id="@+id/authkey0"
                android:layout_width="235dp"
                android:layout_height="wrap_content"
                android:layout_marginLeft="8dp"
                android:background="@drawable/shape4border"
                android:digits="0123456789ABCDEFabcdef"
                android:gravity="center"
                android:inputType="textCapCharacters"
                android:maxLength="32"
                android:maxLines="1"
                android:text="FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
                android:textSize="12sp"
                app:layout_constraintBottom_toBottomOf="@+id/textView5"
                app:layout_constraintLeft_toRightOf="@+id/textView5"
                app:layout_constraintTop_toTopOf="@+id/textView5" />

            <TextView
                android:id="@+id/textView6"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="5dp"
                android:text="32位16进制新建密钥:"
                android:textSize="12sp"
                app:layout_constraintLeft_toLeftOf="parent"
                app:layout_constraintTop_toBottomOf="@+id/textView5" />

            <EditText
                android:id="@+id/newkey"
                android:layout_width="235dp"
                android:layout_height="wrap_content"
                android:layout_marginLeft="8dp"
                android:background="@drawable/shape4border"
                android:digits="0123456789ABCDEFabcdef"
                android:gravity="center"
                android:inputType="textCapCharacters"
                android:maxLength="32"
                android:maxLines="1"
                android:text="FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
                android:textSize="12sp"
                app:layout_constraintBottom_toBottomOf="@+id/textView6"
                app:layout_constraintLeft_toRightOf="@+id/textView6"
                app:layout_constraintTop_toTopOf="@+id/textView6" />

            <Button
                android:id="@+id/butt_readfile"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="8dp"
                android:onClick="cpu_readfile"
                android:text="读文件数据"
                android:textSize="11sp"
                app:layout_constraintLeft_toLeftOf="parent"
                app:layout_constraintTop_toBottomOf="@+id/textView6" />

            <Button
                android:id="@+id/butt_writeeasyfile"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:onClick="cpu_writeeasyfile"
                android:text="写数据到易写文件"
                android:textSize="11sp"
                app:layout_constraintBottom_toBottomOf="@+id/butt_readfile"
                app:layout_constraintLeft_toRightOf="@+id/butt_readfile"
                app:layout_constraintTop_toTopOf="@+id/butt_readfile" />

            <Button
                android:id="@+id/butt_writefile"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:onClick="cpu_writefile"
                android:text="写数据到标准文件"
                android:textSize="11sp"
                app:layout_constraintBottom_toBottomOf="@+id/butt_writeeasyfile"
                app:layout_constraintLeft_toRightOf="@+id/butt_writeeasyfile"
                app:layout_constraintTop_toTopOf="@+id/butt_writeeasyfile" />

            <TextView
                android:id="@+id/textviewrwfile"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="请选择:"
                android:textSize="12sp"
                app:layout_constraintLeft_toLeftOf="parent"
                app:layout_constraintTop_toBottomOf="@+id/butt_readfile" />

            <Spinner
                android:id="@+id/spin_SelRWfile"
                android:layout_width="180dp"
                android:layout_height="wrap_content"
                android:entries="@array/cpucardfile"
                android:textSize="11sp"
                app:layout_constraintBottom_toBottomOf="@+id/textviewrwfile"
                app:layout_constraintLeft_toRightOf="@+id/textviewrwfile"
                app:layout_constraintTop_toTopOf="@+id/textviewrwfile" />

            <Spinner
                android:id="@+id/spin_SelRWauthkey"
                android:layout_width="180dp"
                android:layout_height="wrap_content"
                android:entries="@array/cpucardauthkey"
                android:textSize="11sp"
                app:layout_constraintBottom_toBottomOf="@+id/spin_SelRWfile"
                app:layout_constraintLeft_toRightOf="@+id/spin_SelRWfile"
                app:layout_constraintTop_toTopOf="@+id/spin_SelRWfile" />

            <TextView
                android:id="@+id/textviewrwauthkey"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="5dp"
                android:text="本次读写文件的认证密钥:"
                android:textSize="12sp"
                app:layout_constraintLeft_toLeftOf="parent"
                app:layout_constraintTop_toBottomOf="@+id/textviewrwfile" />

            <EditText
                android:id="@+id/editrwauthkey"
                android:layout_width="235dp"
                android:layout_height="wrap_content"
                android:layout_marginLeft="8dp"
                android:background="@drawable/shape4border"
                android:digits="0123456789ABCDEFabcdef"
                android:gravity="center"
                android:inputType="textCapCharacters"
                android:maxLength="32"
                android:maxLines="1"
                android:text="FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
                android:textSize="12sp"
                app:layout_constraintBottom_toBottomOf="@+id/textviewrwauthkey"
                app:layout_constraintLeft_toRightOf="@+id/textviewrwauthkey"
                app:layout_constraintTop_toTopOf="@+id/textviewrwauthkey" />


            <TextView
                android:id="@+id/textviewrwbegin"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="5dp"
                android:text="本次读写文件的起始地址:"
                android:textSize="12sp"
                app:layout_constraintLeft_toLeftOf="parent"
                app:layout_constraintTop_toBottomOf="@+id/textviewrwauthkey" />

            <EditText
                android:id="@+id/textrwbeginadd"
                android:layout_width="40dp"
                android:layout_height="wrap_content"
                android:layout_marginLeft="8dp"
                android:background="@drawable/shape4border"
                android:textColor="#FF0000"
                android:gravity="center"
                android:text="0"
                android:textSize="12sp"
                app:layout_constraintBottom_toBottomOf="@+id/textviewrwbegin"
                app:layout_constraintLeft_toRightOf="@+id/textviewrwbegin"
                app:layout_constraintTop_toTopOf="@+id/textviewrwbegin" />

            <TextView
                android:id="@+id/textviewrwlen"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginLeft="52dp"
                android:text="本次读写长度:"
                android:textSize="12sp"
                app:layout_constraintBottom_toBottomOf="@+id/textviewrwbegin"
                app:layout_constraintLeft_toRightOf="@+id/textrwbeginadd"
                app:layout_constraintTop_toTopOf="@+id/textviewrwbegin"
                app:layout_constraintVertical_bias="1.0" />

            <EditText
                android:id="@+id/textrwlen"
                android:layout_width="40dp"
                android:layout_height="wrap_content"
                android:layout_marginLeft="8dp"
                android:background="@drawable/shape4border"
                android:textColor="#FF0000"
                android:gravity="center"
                android:text="100"
                android:textSize="12sp"
                app:layout_constraintBottom_toBottomOf="@+id/textviewrwlen"
                app:layout_constraintLeft_toRightOf="@+id/textviewrwlen"
                app:layout_constraintTop_toTopOf="@+id/textviewrwlen" />

            <EditText
                android:id="@+id/editrwdata"
                android:layout_width="match_parent"
                android:layout_height="80dp"
                android:layout_marginTop="5dp"
                android:background="@drawable/shape4border"
                android:digits="0123456789ABCDEFabcdef"
                android:inputType="textCapCharacters"
                android:maxLines="8"
                android:text="                                               "
                android:textSize="12sp"
                app:layout_constraintLeft_toLeftOf="parent"
                app:layout_constraintTop_toBottomOf="@+id/textviewrwbegin" />

            <Button
                android:id="@+id/butt_clearcupcard"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="8dp"
                android:onClick="cpu_cardclr"
                android:text="强制清空已初始化过的CPU卡"
                android:textSize="11sp"
                app:layout_constraintLeft_toLeftOf="parent"
                app:layout_constraintTop_toBottomOf="@+id/editrwdata" />

        </androidx.constraintlayout.widget.ConstraintLayout>

    </ScrollView>

</androidx.constraintlayout.widget.ConstraintLayout>
package com.usbreadertest;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;

import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.Spinner;
import android.widget.TextView;

import com.reader.ourmifare;
public class CpuCardActivity extends AppCompatActivity {
    private TextView tv;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_cpu_card);
        androidx.appcompat.widget.Toolbar toolbar=findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);

        tv = findViewById(R.id.sample_text);
        tv.setText("操作结果");

        Spinner spls = findViewById(R.id.spin_SelRWauthkey);
        spls.setSelection(1);
    }

    @Override
    public void onBackPressed(){
        super.onBackPressed();
        finish();
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        if(item.getItemId()==android.R.id.home){
            finish();
            return true;
        }
        return super.onOptionsItemSelected(item);
    }

    public void retmain(View view)
    {
        finish();
    }


    public void cpu_request(View view){
        byte status;                         //存放返回值
        byte[] mypiccserial = new byte[4];   //4字节设备编号
        byte[] myparam = new byte[4];        //4字节卡参数
        byte[] myver= new byte[1];
        byte[] mycode= new byte[1];

        TextView ctrcarduid;
        ctrcarduid = findViewById(R.id.textcarduid);
        ctrcarduid.setText("");

        tv = findViewById(R.id.sample_text);
        tv.setText("");

        status =ourmifare.cpurequest(mypiccserial,myparam, myver, mycode);
        if (status == 0 || status == 52) {
            ourmifare.pcdbeep(38);
            String serialnumber = "";
            for (int i = 0; i < 4; i++) {
                String bytestr = "00" + Integer.toHexString(mypiccserial[i] & 0xff);
                serialnumber = serialnumber + bytestr.substring(bytestr.length() - 2, bytestr.length());
            }
            ctrcarduid.setText(serialnumber);
            tv.setText("CPU卡已激活,卡号:"+serialnumber);
        } else {
            PrintErrInf(status);   //返回代码提示
        }
    }

    public void cpu_rsinit(View view){
        byte status;                         //存放返回值
        byte[] mypicckey = new byte[16];     //卡片认证密码,16进制,最好不要随便修改,此密码不影响数据安全
        byte mykeylen = 16 ;                 //卡片密码长度
        int  spacesize;                      //应用空间字节大小(要大于所有文件总和),根据不同容量的卡设不同值
        byte emptycard;                      //初始化前是否清空卡内数据,取值1将先清空卡,取值为0不清空现有数据

        String cardkeystr;
        CheckBox ctrcheck;
        EditText ctrcardkey;
        EditText ctrspace;

        ctrcheck=findViewById(R.id.checkcleckcard) ;
        if(ctrcheck.isChecked()) {
            emptycard=1;
        }else {emptycard=0;}

        ctrspace=findViewById(R.id.textusespace) ;
        spacesize=Integer.parseInt(ctrspace.getText().toString().trim());

        ctrcardkey=findViewById(R.id.cardkey) ;
        cardkeystr=ctrcardkey.getText().toString().trim();
        if (cardkeystr.length() < 32)
        {
            tv.setText("卡密钥是32位16进制数据,请输入正确的卡片密钥!");
            return;
        }else {
            for (int i = 0; i < 16; i++) {
                mypicckey[i] = (byte) Integer.parseInt(cardkeystr.substring(i * 2, i * 2 + 2), 16);//只有用Integer.parseInt才能杜绝大于128时的错误
            }
        }

        status =ourmifare.cpursinit(emptycard, mypicckey, mykeylen, spacesize);
        if (status == 0 ) {
            ourmifare.pcdbeep(38);
            tv.setText("初始化卡成功!" );
        } else {
            PrintErrInf(status);   //返回代码提示
        }
    }

    public void cpu_rseasyfileadd(View view){
        byte status;                         //存放返回值
        byte RKLen = 16 ;                    //文件 只读权限密码 长度
        byte[] RFilekey = new byte[RKLen];   //文件 只读权限密码
        byte WKLen = 16 ;                    //文件 读写权限密码 长度
        byte[] WFilekey = new byte[WKLen];   //文件 读写权限密码,此权限高,可认证此密码修改只读密码,要记住文件密码

        Spinner spls = findViewById(R.id.spin_SelCreatefilenum);
        byte FileIndex = (byte)(spls.getSelectedItemId());   //指定文件号

        EditText ctrfilesize = findViewById(R.id.textfileszie);  //文件大小
        int FileSize=Integer.parseInt(ctrfilesize.getText().toString().trim());

        EditText ctrreadkey=findViewById(R.id.readkey) ;
        String readkeystr=ctrreadkey.getText().toString().trim();
        if (readkeystr.length() < 32)
        {
            tv.setText("文件只读密钥是32位16进制数据,请输入正确的只读密钥!");
            return;
        }else {
            for (int i = 0; i < 16; i++) {
                RFilekey[i] = (byte) Integer.parseInt(readkeystr.substring(i * 2, i * 2 + 2), 16);//只有用Integer.parseInt才能杜绝大于128时的错误
            }
        }

        EditText ctrwritekey=findViewById(R.id.writekey) ;
        String writekeystr=ctrwritekey.getText().toString().trim();
        if (writekeystr.length() < 32)
        {
            tv.setText("文件读写密钥是32位16进制数据,请输入正确的读写密钥!");
            return;
        }else {
            for (int i = 0; i < 16; i++) {
                WFilekey[i] = (byte) Integer.parseInt(writekeystr.substring(i * 2, i * 2 + 2), 16);//只有用Integer.parseInt才能杜绝大于128时的错误
            }
        }

        status =ourmifare.cpursfileadds(FileIndex, RFilekey, RKLen, WFilekey, WKLen, FileSize) ;  //
        if (status == 0 ) {
            ourmifare.pcdbeep(38);
            tv.setText(Integer.toHexString(FileIndex+1)+" 号文件创建成功!");
        } else {
            PrintErrInf(status);   //返回代码提示
        }
    }

    public void cpu_rsfileadd(View view){
        byte status;                         //存放返回值
        byte RKLen = 16 ;                    //文件 只读权限密码 长度
        byte[] RFilekey = new byte[RKLen];   //文件 只读权限密码
        byte WKLen = 16 ;                    //文件 读写权限密码 长度
        byte[] WFilekey = new byte[WKLen];   //文件 读写权限密码,此权限高,可认证此密码修改只读密码,要记住文件密码

        Spinner spls = findViewById(R.id.spin_SelCreatefilenum);
        byte FileIndex = (byte)(spls.getSelectedItemId());   //指定文件号

        EditText ctrfilesize = findViewById(R.id.textfileszie);  //文件大小
        int FileSize=Integer.parseInt(ctrfilesize.getText().toString().trim());

        EditText ctrreadkey=findViewById(R.id.readkey) ;
        String readkeystr=ctrreadkey.getText().toString().trim();
        if (readkeystr.length() < 32)
        {
            tv.setText("文件只读密钥是32位16进制数据,请输入正确的只读密钥!");
            return;
        }else {
            for (int i = 0; i < 16; i++) {
                RFilekey[i] = (byte) Integer.parseInt(readkeystr.substring(i * 2, i * 2 + 2), 16);//只有用Integer.parseInt才能杜绝大于128时的错误
            }
        }

        EditText ctrwritekey=findViewById(R.id.writekey) ;
        String writekeystr=ctrwritekey.getText().toString().trim();
        if (writekeystr.length() < 32)
        {
            tv.setText("文件读写密钥是32位16进制数据,请输入正确的读写密钥!");
            return;
        }else {
            for (int i = 0; i < 16; i++) {
                WFilekey[i] = (byte) Integer.parseInt(writekeystr.substring(i * 2, i * 2 + 2), 16);//只有用Integer.parseInt才能杜绝大于128时的错误
            }
        }

        status =ourmifare.cpursfileadd(FileIndex, RFilekey, RKLen, WFilekey, WKLen, FileSize) ;  //
        if (status == 0 ) {
            ourmifare.pcdbeep(38);
            tv.setText(Integer.toHexString(FileIndex+1)+" 号文件创建成功!");
        } else {
            PrintErrInf(status);   //返回代码提示
        }
    }

    public void cpu_rsfilekeychg(View view){
        byte status;                         //存放返回值
        byte OldKey;
        byte AKLen = 16 ;                    //文件 认证密码 长度
        byte[] Autkey = new byte[AKLen];     //文件 认证密码
        byte NKLen = 16 ;                    //文件 新密码密码 长度
        byte[] Newkey = new byte[NKLen];     //文件 新密码密码

        Spinner spls = findViewById(R.id.spin_Selchangkeyfile);
        byte FileIndex = (byte)(spls.getSelectedItemId());   //指定文件号

        Spinner spcharw = findViewById(R.id.spin_SelchangRWkey);
        byte ChaKey= (byte)(spcharw.getSelectedItemId());       //取值 0 表示用只读密码来认证,取值 2 表示用读写密码来认证

        Spinner spsuthkey = findViewById(R.id.spin_Selauthkey);
        if (spsuthkey.getSelectedItemId()==0) {
            OldKey = 0;               //取值 0 表示用只读密码来认证,取值 2 表示用读写密码来认证
        }else {OldKey=2;}

        byte ctrlCode=(byte)(ChaKey+OldKey);

        EditText ctrauthkey=findViewById(R.id.authkey0) ;
        String authkeystr=ctrauthkey.getText().toString().trim();
        if (authkeystr.length() < 32)
        {
             tv.setText("文件认证密钥是32位16进制数据,请输入正确的认证密钥!");
             return;
        }else {
            for (int i = 0; i < 16; i++) {
                Autkey[i] = (byte) Integer.parseInt(authkeystr.substring(i * 2, i * 2 + 2), 16);//只有用Integer.parseInt才能杜绝大于128时的错误
            }
        }

        EditText ctrnewkey=findViewById(R.id.newkey) ;
        String newkeystr=ctrnewkey.getText().toString().trim();
        if (newkeystr.length() < 32)
        {
            tv.setText("文件新密钥是32位16进制数据,请输入正确的新密钥!");
            return;
        }else {
            for (int i = 0; i < 16; i++) {
                Newkey[i] = (byte) Integer.parseInt(newkeystr.substring(i * 2, i * 2 + 2), 16);//只有用Integer.parseInt才能杜绝大于128时的错误
            }
        }

        status =ourmifare.cpursfilekeychg(FileIndex, ctrlCode, Autkey, AKLen, Newkey, NKLen) ;//& 0xff用于转为无符号行数据
        if (status == 0 ) {
            ourmifare.pcdbeep(38);
            tv.setText(Integer.toHexString(FileIndex+1)+" 号文件密码修改成功!" );
        } else {
            PrintErrInf(status);   //返回代码提示
        }
    }

    public void cpu_readfile(View view){
        byte status;                          //存放返回值
        byte AKLen = 16 ;                     //文件 认证密码 长度
        byte[] Autkey = new byte[AKLen];      //文件 认证密码
        byte DataStart=0;                     //读起始位置
        byte DataLen = 0 ;                   //读长度最大不能超过255,如文件长度>255 要循环读取
        byte[] DataBuf = new byte[300];      //读文件数据缓冲
        byte ctrlCode=0;                     //取值 0 表示用只读密码来认证,取值 2 表示用读写密码来认证

        EditText ctrrwdata = findViewById(R.id.editrwdata);
        ctrrwdata.setText("");

        Spinner spls = findViewById(R.id.spin_SelRWfile);
        byte FileIndex = (byte)(spls.getSelectedItemId());   //指定文件号

        Spinner spsuthkey = findViewById(R.id.spin_SelRWauthkey);
        if (spsuthkey.getSelectedItemId()==0) {
            ctrlCode = 0;               //取值 0 表示用只读密码来认证,取值 2 表示用读写密码来认证
        }else {ctrlCode=2;}

        EditText ctrauthkey=findViewById(R.id.editrwauthkey) ;
        String authkeystr=ctrauthkey.getText().toString().trim();
        if (authkeystr.length() < 32)
        {
            tv.setText("文件认证密钥是32位16进制数据,请输入正确的认证密钥!");
            return;
        }else {
            for (int i = 0; i < 16; i++) {
                Autkey[i] = (byte) Integer.parseInt(authkeystr.substring(i * 2, i * 2 + 2), 16);//只有用Integer.parseInt才能杜绝大于128时的错误
            }
        }

        EditText ctrbeginadd = findViewById(R.id.textrwbeginadd);  //操作起始地址
        DataStart=(byte)Integer.parseInt(ctrbeginadd.getText().toString().trim());

        EditText ctrrwlen = findViewById(R.id.textrwlen);          //读写长度
        DataLen=(byte)Integer.parseInt(ctrrwlen.getText().toString().trim());

        if (DataLen<1 || DataLen>255){
            tv.setText("一次读取的数据长度应大于0,小于256!如要读取更多的数据请使用循环的方式读取。");
            return;
        }

        status = ourmifare.cpursfiledataread(FileIndex, ctrlCode, Autkey, AKLen, DataStart, DataBuf,DataLen) ;//& 0xff用于转为无符号行数据
        if (status == 0 ) {
            ourmifare.pcdbeep(38);
            String filedata="";
            for (int i = 0; i < DataLen; i++) {
                String bytestr = "00" + Integer.toHexString(DataBuf[i] & 0xff);
                filedata = filedata + bytestr.substring(bytestr.length() - 2, bytestr.length()) +" ";
            }

            ctrrwdata.setText(filedata);
        } else {
            PrintErrInf(status);   //返回代码提示
        }
    }

    public void cpu_writeeasyfile(View view){
        byte status;                          //存放返回值
        byte AKLen = 16 ;                    //文件 认证密码 长度
        byte[] Autkey = new byte[AKLen];     //文件 认证密码
        byte DataStart=0;                    //写起始位置
        byte DataLen  ;                      //写长度最大不能超过247,如文件长度>247 要循环写入
        byte[] DataBuf = new byte[300];      //写文件数据缓冲
        byte ctrlCode=0;                     //取值 0 表示用只读密码来认证,取值 2 表示用读写密码来认证

        Spinner spls = findViewById(R.id.spin_SelRWfile);
        byte FileIndex = (byte)(spls.getSelectedItemId());   //指定文件号

        Spinner spsuthkey = findViewById(R.id.spin_SelRWauthkey);
        if (spsuthkey.getSelectedItemId()==0) {
            ctrlCode = 0;               //取值 0 表示用只读密码来认证,取值 2 表示用读写密码来认证
        }else {ctrlCode=2;}

        EditText ctrauthkey=findViewById(R.id.editrwauthkey) ;
        String authkeystr=ctrauthkey.getText().toString().trim();
        if (authkeystr.length() < 32)
        {
            tv.setText("文件认证密钥是32位16进制数据,请输入正确的认证密钥!");
            return;
        }else {
            for (int i = 0; i < 16; i++) {
                Autkey[i] = (byte) Integer.parseInt(authkeystr.substring(i * 2, i * 2 + 2), 16);//只有用Integer.parseInt才能杜绝大于128时的错误
            }
        }

        EditText ctrbeginadd = findViewById(R.id.textrwbeginadd);  //操作起始地址
        DataStart=(byte)Integer.parseInt(ctrbeginadd.getText().toString().trim());

        EditText ctrrwlen = findViewById(R.id.textrwlen);          //读写长度
        DataLen=(byte)Integer.parseInt(ctrrwlen.getText().toString().trim());

        if (DataLen<1 || DataLen>247){
            tv.setText("一次写入的数据长度应大于0,小于248,如要写入更多的数据可使用循环的方式写入。");
            return;
        }

        EditText ctrrwdata = findViewById(R.id.editrwdata);        //读写数据
        String rwdatahex=ctrrwdata.getText().toString().trim();
        String[] strArr = rwdatahex.split("\\ ");    /*分割接收到的数据后再分析、处理、返回指令 */
        if (strArr.length<DataLen){
            tv.setText("写入数据不足,请输入"+Integer.toString(DataLen*2)+"位16进制写入数据!");
            return;
        }else{
            for(int p=0;p<strArr.length;p++) {
                DataBuf[p]=(byte)(Integer.parseInt(strArr[p],16));
            }
        }

        status =ourmifare.cpursfiledatawrites(FileIndex, ctrlCode, Autkey, AKLen, DataStart, DataBuf,DataLen) ;//& 0xff用于转为无符号行数据
        if (status == 0 ) {
            ourmifare.pcdbeep(38);
            tv.setText("写数据成功!" );
        } else {
            PrintErrInf(status);   //返回代码提示
        }
    }

    public void cpu_writefile(View view){
        byte status;                          //存放返回值
        byte AKLen = 16 ;                    //文件 认证密码 长度
        byte[] Autkey = new byte[AKLen];     //文件 认证密码
        byte DataStart=0;                    //写起始位置
        byte DataLen  ;                      //写长度最大不能超过247,如文件长度>247 要循环写入
        byte[] DataBuf = new byte[300];      //写文件数据缓冲
        byte ctrlCode=0;                     //取值 0 表示用只读密码来认证,取值 2 表示用读写密码来认证

        Spinner spls = findViewById(R.id.spin_SelRWfile);
        byte FileIndex = (byte)(spls.getSelectedItemId());   //指定文件号

        Spinner spsuthkey = findViewById(R.id.spin_SelRWauthkey);
        if (spsuthkey.getSelectedItemId()==0) {
            ctrlCode = 0;               //取值 0 表示用只读密码来认证,取值 2 表示用读写密码来认证
        }else {ctrlCode=2;}

        EditText ctrauthkey=findViewById(R.id.editrwauthkey) ;
        String authkeystr=ctrauthkey.getText().toString().trim();
        if (authkeystr.length() < 32)
        {
            tv.setText("文件认证密钥是32位16进制数据,请输入正确的认证密钥!");
            return;
        }else {
            for (int i = 0; i < 16; i++) {
                Autkey[i] = (byte) Integer.parseInt(authkeystr.substring(i * 2, i * 2 + 2), 16);//只有用Integer.parseInt才能杜绝大于128时的错误
            }
        }

        EditText ctrbeginadd = findViewById(R.id.textrwbeginadd);  //操作起始地址
        DataStart=(byte)Integer.parseInt(ctrbeginadd.getText().toString().trim());

        EditText ctrrwlen = findViewById(R.id.textrwlen);          //读写长度
        DataLen=(byte)Integer.parseInt(ctrrwlen.getText().toString().trim());

        if (DataLen<1 || DataLen>247){
            tv.setText("一次写入的数据长度应大于0,小于248,如要写入更多的数据可使用循环的方式写入。");
            return;
        }

        EditText ctrrwdata = findViewById(R.id.editrwdata);        //读写数据
        String rwdatahex=ctrrwdata.getText().toString().trim();
        String[] strArr = rwdatahex.split("\\ ");    /*分割接收到的数据后再分析、处理、返回指令 */
        if (strArr.length<DataLen){
            tv.setText("写入数据不足,请输入"+Integer.toString(DataLen*2)+"位16进制写入数据!");
            return;
        }else{
            for(int p=0;p<strArr.length;p++) {
                DataBuf[p]=(byte)(Integer.parseInt(strArr[p],16));
            }
        }

        status =ourmifare.cpursfiledatawrite(FileIndex, ctrlCode, Autkey, AKLen, DataStart, DataBuf,DataLen) ;//& 0xff用于转为无符号行数据
        if (status == 0 ) {
            ourmifare.pcdbeep(38);
            tv.setText("写数据成功!" );
        } else {
            PrintErrInf(status);   //返回代码提示
        }
    }

    public void cpu_cardclr(View view){
        byte status=ourmifare.cpurscardclr() ;//& 0xff用于转为无符号行数据
        if (status == 0 ) {
            ourmifare.pcdbeep(38);
            tv.setText("强制清空卡成功!");
        } else if(status == 64){
            tv.setText("此卡为未经过我们cpursinit函数成功初始化的卡!");
        }else{
            PrintErrInf(status);   //返回代码提示
        }
    }
    public void PrintErrInf(byte errcode) {
        String dispstr;
        switch(errcode){
            case 8:
                dispstr="错误代码:8,未寻到卡,请重新拿开卡后再放到感应区!";
                break;
            case 21:
                dispstr="错误代码:21,没有动态库!";
                break;
            case 22:
                dispstr="错误代码:22,动态库或驱动程序异常!";
                break;
            case 23:
                dispstr="错误代码:23,驱动程序错误或尚未安装!";
                break;
            case 24:
                dispstr="错误代码:24,操作超时,一般是动态库没有反映!";
                break;
            case 25:
                dispstr="错误代码:25,发送字数不够!";
                break;
            case 26:
                dispstr="错误代码:26,发送的CRC错!";
                break;
            case 27:
                dispstr="错误代码:27,接收的字数不够!";
                break;
            case 28:
                dispstr="错误代码:28,接收的CRC错!";
                break;
            case 50:
                dispstr="错误代码:50,RATS错误,厂家调试代码,用户不需理会!";
                break;
            case 51:
                dispstr="错误代码:51,PPS错误,厂家调试代码,用户不需理会!";
                break;
            case 52:
                dispstr="错误代码:52,已进入了14443-4协议状态,可进行CPU卡功能所有操作了!";
                break;
            case 53:
                dispstr="错误代码:53,CPU卡功能通讯错误,请先激活卡片!";
                break;
            case 54:
                dispstr="错误代码:54,数据不足,需要接着发送未完成的数据至卡上!";
                break;
            case 55:
                dispstr="错误代码:55,发送ACK指令给卡,让卡接着发送数据回来!";
                break;
            case 56:
                dispstr="错误代码:56,清空根目录失败!";
                break;
            case 57:
                dispstr="错误代码:57,卡片不支持功能!";
                break;
            case 58:
                dispstr="错误代码:58,卡片初始化失败!";
                break;
            case 59:
                dispstr="错误代码:59,分配的空间不足!";
                break;
            case 60:
                dispstr="错误代码:60,本次操作的实体已存在!";
                break;
            case 61:
                dispstr="错误代码:61,无足够空间!";
                break;
            case 62:
                dispstr="错误代码:62,文件不存在!";
                break;
            case 63:
                dispstr="错误代码:63,权限不足,有可能是用只读密码认证,导致无法更改读写密码或无法写文件!";
                break;
            case 64:
                dispstr="错误代码:64,密码不存在,或密钥文件未创建!";
                break;
            case 65:
                dispstr="错误代码:65,传送长度错误!";
                break;
            case 66:
                dispstr="错误代码:66,Le错误,即接收的数据长度指定过大!";
                break;
            case 67:
                dispstr="错误代码:67,功能不支持或卡中无MF 或卡片已锁定!";
                break;
            case 68:
                dispstr="错误代码:68,密码认证错误次数过多,该密码已被锁死!";
                break;
            case 70:
            case 71:
            case 72:
            case 73:
            case 74:
            case 75:
            case 76:
            case 77:
            case 78:
            case 79:
            case 80:
            case 81:
            case 82:
            case 83:
            case 84:
            case 85:
                dispstr="错误代码:"+Integer.toString(errcode)+",密码错误,剩余次数为"+Integer.toString(errcode-70)+",如果为0,该密码将锁死,无法再认证!";
                break;
            case 86:
                dispstr="错误代码:"+Integer.toString(errcode)+",更改后的密码长度必须和创建时的长度一致!";
                break;
            case 87:
                dispstr="错误代码:"+Integer.toString(errcode)+",应用目录不存在!";
                break;
            case 88:
                dispstr="错误代码:"+Integer.toString(errcode)+",应用文件不存在!";
                break;
            case 89:
                dispstr="错误代码:"+Integer.toString(errcode)+",文件号不能超过 5 ";
                break;
            case 90:
                dispstr="错误代码:"+Integer.toString(errcode)+",读取文件时返回的长度不足,数据可能不正确!";
                break;
            case 91:
                dispstr="错误代码:"+Integer.toString(errcode)+",一次读文件的长度不能超过 255";
                break;
            case 92:
                dispstr="错误代码:"+Integer.toString(errcode)+",一次写文件的长度不能超过 247";
                break;
            default:
                dispstr="未知错误,错误代码:"+Integer.toString(errcode);
                break;
        }
        tv = findViewById(R.id.sample_text);
        tv.setText(dispstr);
    }
}

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1354597.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

redis复习笔记02(小滴课堂)

分布式缓存Redis6常见核心配置讲解 查看配置文件&#xff1a; 创建配置文件&#xff1a; 配置完我们去验证一下&#xff1a; 启动成功就没有问题了。 可以看到redis日志。 然后我们就可以连接我们的redis了&#xff1a; 设置了密码就需要密码登录了。 如果登录了错误的密码也无…

C/C++汇编学习(二)——学习使用IDA pro

学习使用IDA Pro是一项很有价值的技能&#xff0c;特别是对于那些对逆向工程和软件安全分析感兴趣的人。以下是一些基本步骤和概念&#xff0c;帮助你熟悉IDA Pro的界面和操作。 1. 熟悉IDA Pro界面和基本操作 主界面布局 IDA Pro的主界面包含多个组件&#xff0c;每个组件都…

静态网页设计——个人简介网站

前言 使用经典前端三件套HTMLCSSJavascript编写了一个关于个人简介的静态网页&#xff0c;可以根据自己的需要&#xff0c;十分简单的进行修改。 首页 首页由上方的菜单栏以及菜单栏下面的轮播图组成&#xff0c;再往下走&#xff0c;是关于自己的兴趣爱好的部分&#xff0c…

UG/NX许可证使用效率提升新技术

UG/NX许可证使用效率提升新技术 UG&#xff08;Unigraphics NX&#xff09;是Siemens PLM Software公司出品的一个产品工程解决方案&#xff0c;它为用户的产品设计及加工过程提供了数字化造型和验证手段。近年来随着国家对知识产品保护的不断加强&#xff0c;以前使用盗版软件…

vue3+Ts+Hook的方式实现商城核心功能sku选择器

前言 Hooks是React等函数式编程框架中非常受欢迎的工具&#xff0c;随着VUE3 Composition API 函数式编程风格的推出&#xff0c;现在也受到越来越多VUE3开发者的青睐&#xff0c;它让开发者的代码具有更高的复用度且更加清晰、易于维护。 本文将通过CRMEB商城商品详情sku选择…

Bee的批量插入与事务使用

* Bee 在2.2之前,调用批量插入在每个批都会提交commit,但在2.2改为只调用一次且在事务中,在批量插入的方法内容不再提交,而由事务控制. * * 2.2之前,批量插入使用每一个批次提交一次事务; * 这样,当违反主键约束等就忽略的大批量插入效率是很高的; * 但当事务中有批量插…

Golang Leetcode19 删除链表的倒数第N个节点 递归 双指针法+迭代

删除链表的倒数第N个节点 leetcode19 递归 由于本体是倒数第几个节点&#xff0c;非常适合递归 从终到始 的运行方式 func removeNthFromEnd(head *ListNode, n int) *ListNode {// 创建一个虚拟头节点&#xff0c;简化边界条件处理dummy : &ListNode{Next: head}//检查…

【卫星科普】什么是农业一号卫星和农业二号卫星?

农业一号卫星和农业二号卫星是中国自主研发的两颗重要卫星&#xff0c;主要用于农业领域的监测和研究。 农业一号卫星是中国第一颗具备红边波段传感器的卫星&#xff0c;也是世界上第一颗具备红边波段的宽视场多光谱中高分辨率卫星。这对农业农村遥感监测非常重要&#xff0c;…

阿里云ECS服务器无法访问端口(防火墙在关闭状态也启作用)

问题&#xff1a;一直用得好好的端口&#xff0c;突然在某一时间不可以访问这个端口了 &#xff0c;在服务器录入外网地址访问如下图&#xff1a; 先按正常流程检测&#xff1a; 1 先云服务商的管理网站查看防火墙端口是否开放 看了正常开放了端口&#xff0c;如下图&#xff…

HTML5-简单文件操作

文件操作 简介 概念&#xff1a;可以通过file类型的input控件或者拖放的方式选择文件进行操作 语法格式&#xff1a; <input type"file" multiple>属性 multiple&#xff1a;表示是否选择多个文件 accept&#xff1a;用于设置文件的过滤类型&#xff08;MI…

Linux 如何 kill 指定的 python 进程

文章目录 写在前面一、显示python相关的进程二、找到自己想要 kill 的进程&#xff0c;执行下述指令 写在前面 自己的系统是 Ubuntu 20.04 一、显示python相关的进程 ps -ef | grep python显示结果如下 其中&#xff0c;第二列分别是各个进程的 PID 号。 二、找到自己想要…

【38 Pandas+Pyecharts | 奥迪汽车销量数据分析可视化】

文章目录 &#x1f3f3;️‍&#x1f308; 1. 导入模块&#x1f3f3;️‍&#x1f308; 2. Pandas数据处理2.1 读取数据2.2 查看数据信息2.3 数据处理 &#x1f3f3;️‍&#x1f308; 3. Pyecharts数据可视化3.1 奥迪用户购车时间分布3.2 奥迪各系销量占比饼图3.3 奥迪各系销量…

使用Python和Pygame库创建简单的的彩球效果

简介 Pygame是一款强大的游戏开发库&#xff0c;可以用于创建各种有趣的图形效果。为了更好地了解Pygame的功能&#xff0c;今天我们将要做的是在屏幕上随机生成一些彩色的小球&#xff0c;并使它们以不同的速度和方向移动。当小球碰到屏幕边缘时&#xff0c;它们将反弹。 功能…

小型洗衣机哪个牌子质量好?五款最好用的迷你洗衣机品牌

不得不说洗衣机的发明解放了我们的双手&#xff0c;而我们从小到大就有这个意识&#xff0c;贴身衣物不可以和普通的衣服一起丢进去洗衣机一起&#xff0c;而内衣裤上不仅有肉眼看见的污渍还有手上根本无法消灭的细菌&#xff0c;但是有一款专门可以将衣物上的细菌杀除的内衣小…

仓库出入库登记系统的推荐

在信息时代&#xff0c;仓库管理已成为企业不可缺少的一项工作。我们如何高效、准确地管理仓库的进货、出货以及库存&#xff0c;是每个企业或仓管都需要面对的问题。而一个优秀的仓库出入库登记系统&#xff0c;则能够大大提升仓库管理的效率和准确性。本文将为您推荐一款实用…

NFC物联网开发在智慧校园中的应用

近年来&#xff0c;校园信息化建设速度加快&#xff0c;以物联网为基础、以各种应用服务系统为载体的智慧校园将教学、管理和校园生活充分融合&#xff0c;形成了工作、学习和生活的一体化环境。沉寂已久的NEC 技术&#xff0c;得益于智能手机的普及、无线网络数据速率提高&…

『开发工具篇』- 配置 gradle 等相关依赖镜像源

『开发工具篇』- 配置 gradle 等相关依赖镜像源 1.更换gradle下载源2. 配置setting.gradlekts文件gradle文件 1.更换gradle下载源 使用腾讯云的镜像库https://mirrors.cloud.tencent.com/gradle/ gradle-x.x-all.zip&#xff1a;编译后的二进制发布版以及源码和文档gradle-x.…

FreeRTOS——优先级翻转

1.优先级翻转概念 优先级翻转&#xff1a;高优先级的任务反而慢执行&#xff0c;低优先级的任务反而优先执行 注意&#xff1a;在实时操作系统中不允许出现&#xff0c;在二值信号量中经常出现 2.优先级翻转实战 2.1freertos_demo.c #include "freertos_demo.h" #i…

1.69寸SPI接口240*280TFT液晶显示模块使用中碰到的问题

1.69寸SPI接口240280TFT液晶显示模块使用中碰到的问题说明并记录一下&#xff0c; 在网上买了1.69寸液晶显示模块&#xff0c;使用spi接口&#xff0c;分辨率240280&#xff0c;给的参考程序是GPIO模拟的SPI接口&#xff0c;打算先移植到FreeRtos测试&#xff0c;再慢慢使用硬件…

Algorithm-Left Edge算法

算法输入&#xff1a; 多个段&#xff0c;每个段由两个值表示&#xff0c;例如&#xff08;1&#xff0c;3&#xff09; 算法原理&#xff1a; 将多个段按照左边的值排序放到列表中遍历列表&#xff0c;不断选择没有重叠的段&#xff0c;直到列表遍历结束&#xff0c;将选择…