安卓Android studio读写EM4305卡源码

news2024/10/1 23:41:32

本示例使用的发卡器: https://item.taobao.com/item.htm?id=718720660087&spm=a1z10.5-c.w4002-21818769070.15.57dc6f89txUhXE

<?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=".EM4305Activity">

    <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="EM4305卡测试页  "
            android:textColor="@color/white"
            android:textSize="16sp"
            android:gravity="center_horizontal|right|center"
            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="150dp"
        android:padding="3dp"
        android:text="操作结果"
        android:textSize="12sp"
        android:background="@drawable/shape4border"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintBottom_toBottomOf="parent"

        />


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

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

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

            <CheckBox
                android:id="@+id/chkPwdEM4305"
                android:layout_width="wrap_content"
                android:layout_height="30dp"
                android:layout_marginLeft="2dp"
                android:checked="false"
                android:text="带密码操作"
                android:textSize="12sp"
                app:layout_constraintLeft_toLeftOf="parent"
                app:layout_constraintTop_toTopOf="parent" />

            <EditText
                android:id="@+id/editTextPwdEM4305"
                android:layout_width="80dp"
                android:layout_height="wrap_content"
                android:layout_marginLeft="10dp"
                android:background="@drawable/shape4border"
                android:digits="0123456789ABCDEFabcdef"
                android:gravity="center"
                android:inputType="textCapCharacters"
                android:maxLength="8"
                android:maxLines="1"
                android:text="00000000"
                android:textSize="14sp"
                app:layout_constraintBottom_toBottomOf="@+id/chkPwdEM4305"
                app:layout_constraintLeft_toRightOf="@+id/chkPwdEM4305"
                app:layout_constraintTop_toTopOf="@+id/chkPwdEM4305"

                />

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginLeft="10dp"
                android:text="(十六进制)"
                android:textSize="12sp"
                app:layout_constraintBottom_toBottomOf="@+id/chkPwdEM4305"
                app:layout_constraintLeft_toRightOf="@+id/editTextPwdEM4305"
                app:layout_constraintTop_toTopOf="@+id/chkPwdEM4305" />


            <CheckBox
                android:id="@+id/chkUidNeedEM4305"
                android:layout_width="wrap_content"
                android:layout_height="30dp"
                android:layout_marginLeft="2dp"
                android:checked="false"
                android:text="仅操作指定卡号的卡"
                android:textSize="12sp"
                app:layout_constraintLeft_toLeftOf="parent"
                app:layout_constraintTop_toBottomOf="@+id/chkPwdEM4305" />

            <EditText
                android:id="@+id/editTextUidEM4305"
                android:layout_width="80dp"
                android:layout_height="wrap_content"
                android:layout_marginLeft="10dp"
                android:background="@drawable/shape4border"
                android:digits="0123456789ABCDEFabcdef"
                android:gravity="center"
                android:inputType="textCapCharacters"
                android:maxLength="8"
                android:maxLines="1"
                android:text="00000000"
                android:textSize="14sp"
                app:layout_constraintBottom_toBottomOf="@+id/chkUidNeedEM4305"
                app:layout_constraintLeft_toRightOf="@+id/chkUidNeedEM4305"
                app:layout_constraintTop_toTopOf="@+id/chkUidNeedEM4305"

                />

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginLeft="10dp"
                android:text="(十六进制)"
                android:textSize="12sp"
                app:layout_constraintBottom_toBottomOf="@+id/chkUidNeedEM4305"
                app:layout_constraintLeft_toRightOf="@+id/editTextUidEM4305"
                app:layout_constraintTop_toTopOf="@+id/chkUidNeedEM4305" />


            <TextView
                android:id="@+id/TextViewlabel6"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="返回数据:"
                android:textSize="12sp"
                app:layout_constraintBottom_toTopOf="@+id/TextViewRetDataEM4305"
                app:layout_constraintLeft_toLeftOf="parent" />

            <TextView
                android:id="@+id/TextViewRetDataEM4305"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:background="@drawable/shape4border"
                android:padding="3dp"
                android:text=""
                android:textSize="12sp"
                app:layout_constraintLeft_toLeftOf="parent"
                app:layout_constraintTop_toBottomOf="@+id/btnRetDataClrEM4305"

                />

            <Button
                android:id="@+id/btnRetDataClrEM4305"
                android:layout_width="wrap_content"
                android:layout_height="40dp"
                android:onClick="textclear4305"
                android:text="清空数据"
                android:textSize="11sp"
                app:layout_constraintRight_toRightOf="parent"
                app:layout_constraintTop_toBottomOf="@+id/editTextUidEM4305" />

            <Button
                android:id="@+id/btnPwdChangeEM4305"
                android:layout_width="wrap_content"
                android:layout_height="40dp"
                android:onClick="changepwd4305"
                android:text="修改卡密码"
                android:textSize="11sp"
                app:layout_constraintRight_toRightOf="parent"
                app:layout_constraintTop_toBottomOf="@+id/TextViewRetDataEM4305" />

            <TextView
                android:id="@+id/TextViewlabel7"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="新密码:"
                android:textSize="12sp"
                app:layout_constraintBottom_toBottomOf="@+id/btnPwdChangeEM4305"
                app:layout_constraintLeft_toLeftOf="parent"
                app:layout_constraintTop_toTopOf="@+id/btnPwdChangeEM4305"

                />

            <EditText
                android:id="@+id/editTextPwdNewEM4305"
                android:layout_width="80dp"
                android:layout_height="wrap_content"
                android:layout_marginLeft="10dp"
                android:background="@drawable/shape4border"
                android:digits="0123456789ABCDEFabcdef"
                android:gravity="center"
                android:inputType="textCapCharacters"
                android:maxLength="8"
                android:maxLines="1"
                android:text="00000000"
                android:textSize="14sp"
                app:layout_constraintBottom_toBottomOf="@+id/btnPwdChangeEM4305"
                app:layout_constraintLeft_toRightOf="@+id/TextViewlabel7"
                app:layout_constraintTop_toTopOf="@+id/btnPwdChangeEM4305" />

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginLeft="10dp"
                android:text="(十六进制)"
                android:textSize="12sp"
                app:layout_constraintBottom_toBottomOf="@+id/editTextPwdNewEM4305"
                app:layout_constraintLeft_toRightOf="@+id/editTextPwdNewEM4305"
                app:layout_constraintTop_toTopOf="@+id/editTextPwdNewEM4305" />


            <CheckBox
                android:id="@+id/chkB0EM4305"
                android:layout_width="wrap_content"
                android:layout_height="30dp"
                android:layout_marginLeft="2dp"
                android:checked="false"
                android:text="块0"
                android:textSize="11sp"
                app:layout_constraintLeft_toLeftOf="parent"
                app:layout_constraintTop_toBottomOf="@+id/btnPwdChangeEM4305" />

            <CheckBox
                android:id="@+id/chkB1EM4305"
                android:layout_width="wrap_content"
                android:layout_height="30dp"
                android:layout_marginLeft="2dp"
                android:checked="false"
                android:text="块1(UID)"
                android:textSize="11sp"
                app:layout_constraintBottom_toBottomOf="@+id/chkB0EM4305"
                app:layout_constraintLeft_toRightOf="@+id/chkB0EM4305" />

            <CheckBox
                android:id="@+id/chkB3EM4305"
                android:layout_width="wrap_content"
                android:layout_height="30dp"
                android:layout_marginLeft="2dp"
                android:checked="false"
                android:text="块3"
                android:textSize="11sp"
                app:layout_constraintBottom_toBottomOf="@+id/chkB0EM4305"
                app:layout_constraintLeft_toRightOf="@+id/chkB1EM4305" />

            <CheckBox
                android:id="@+id/chkB4EM4305"
                android:layout_width="wrap_content"
                android:layout_height="30dp"
                android:layout_marginLeft="2dp"
                android:checked="false"
                android:text="块4(配置)"
                android:textSize="12sp"
                app:layout_constraintBottom_toBottomOf="@+id/chkB0EM4305"
                app:layout_constraintLeft_toRightOf="@+id/chkB3EM4305" />

            <CheckBox
                android:id="@+id/chkB5EM4305"
                android:layout_width="wrap_content"
                android:layout_height="30dp"
                android:layout_marginLeft="2dp"
                android:checked="false"
                android:text="块5"
                android:textSize="12sp"
                app:layout_constraintBottom_toBottomOf="@+id/chkB0EM4305"
                app:layout_constraintLeft_toRightOf="@+id/chkB4EM4305" />

            <CheckBox
                android:id="@+id/chkB6EM4305"
                android:layout_width="wrap_content"
                android:layout_height="30dp"
                android:layout_marginLeft="2dp"
                android:checked="false"
                android:text="块6"
                android:textSize="11sp"
                app:layout_constraintBottom_toBottomOf="@+id/chkB0EM4305"
                app:layout_constraintLeft_toRightOf="@+id/chkB5EM4305" />

            <CheckBox
                android:id="@+id/chkB7EM4305"
                android:layout_width="wrap_content"
                android:layout_height="30dp"
                android:layout_marginLeft="2dp"
                android:checked="false"
                android:text="块7"
                android:textSize="12sp"
                app:layout_constraintLeft_toLeftOf="parent"
                app:layout_constraintTop_toBottomOf="@+id/chkB0EM4305" />


            <CheckBox
                android:id="@+id/chkB8EM4305"
                android:layout_width="wrap_content"
                android:layout_height="30dp"
                android:layout_marginLeft="2dp"
                android:checked="false"
                android:text="块8"
                android:textSize="11sp"
                app:layout_constraintBottom_toBottomOf="@+id/chkB7EM4305"
                app:layout_constraintLeft_toRightOf="@+id/chkB7EM4305" />

            <CheckBox
                android:id="@+id/chkB9EM4305"
                android:layout_width="wrap_content"
                android:layout_height="30dp"
                android:layout_marginLeft="2dp"
                android:checked="false"
                android:text="块9"
                android:textSize="11sp"
                app:layout_constraintBottom_toBottomOf="@+id/chkB8EM4305"
                app:layout_constraintLeft_toRightOf="@+id/chkB8EM4305" />

            <CheckBox
                android:id="@+id/chkB10EM4305"
                android:layout_width="wrap_content"
                android:layout_height="30dp"
                android:layout_marginLeft="2dp"
                android:checked="false"
                android:text="块10"
                android:textSize="11sp"
                app:layout_constraintBottom_toBottomOf="@+id/chkB8EM4305"
                app:layout_constraintLeft_toRightOf="@+id/chkB9EM4305" />

            <CheckBox
                android:id="@+id/chkB11EM4305"
                android:layout_width="wrap_content"
                android:layout_height="30dp"
                android:layout_marginLeft="2dp"
                android:checked="false"
                android:text="块11"
                android:textSize="11sp"
                app:layout_constraintBottom_toBottomOf="@+id/chkB8EM4305"
                app:layout_constraintLeft_toRightOf="@+id/chkB10EM4305" />

            <CheckBox
                android:id="@+id/chkB12EM4305"
                android:layout_width="wrap_content"
                android:layout_height="30dp"
                android:layout_marginLeft="2dp"
                android:checked="false"
                android:text="块12"
                android:textSize="11sp"
                app:layout_constraintBottom_toBottomOf="@+id/chkB8EM4305"
                app:layout_constraintLeft_toRightOf="@+id/chkB11EM4305" />

            <CheckBox
                android:id="@+id/chkB13EM4305"
                android:layout_width="wrap_content"
                android:layout_height="30dp"
                android:layout_marginLeft="2dp"
                android:checked="false"
                android:text="块13"
                android:textSize="11sp"
                app:layout_constraintBottom_toBottomOf="@+id/chkB8EM4305"
                app:layout_constraintLeft_toRightOf="@+id/chkB12EM4305" />

            <CheckBox
                android:id="@+id/chkB14EM4305"
                android:layout_width="wrap_content"
                android:layout_height="30dp"
                android:layout_marginLeft="2dp"
                android:checked="false"
                android:text="块14"
                android:textSize="11sp"
                app:layout_constraintLeft_toLeftOf="parent"
                app:layout_constraintTop_toBottomOf="@+id/chkB8EM4305" />

            <CheckBox
                android:id="@+id/chkB15EM4305"
                android:layout_width="wrap_content"
                android:layout_height="30dp"
                android:layout_marginLeft="2dp"
                android:checked="false"
                android:text="块15"
                android:textSize="11sp"
                app:layout_constraintBottom_toBottomOf="@+id/chkB14EM4305"
                app:layout_constraintLeft_toRightOf="@+id/chkB14EM4305" />

            <TextView
                android:id="@+id/TextViewlabel10"
                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/chkB14EM4305" />

            <EditText
                android:id="@+id/editTextDataEM4305"
                android:layout_width="0dp"
                android:layout_height="40dp"
                android:background="@drawable/shape4border"
                android:digits="0123456789ABCDEFabcdef"
                android:gravity="left"
                android:inputType="textCapCharacters"
                android:maxLength="128"
                android:padding="3dp"
                android:text="11111111"
                android:textSize="12sp"
                app:layout_constraintLeft_toLeftOf="@+id/TextViewRetDataEM4305"
                app:layout_constraintRight_toRightOf="@+id/TextViewRetDataEM4305"
                app:layout_constraintTop_toBottomOf="@+id/TextViewlabel10" />

            <Button
                android:id="@+id/btnReadEM4305"
                android:layout_width="wrap_content"
                android:layout_height="40dp"
                android:layout_marginRight="20dp"
                android:onClick="read4305"
                android:text="读卡"
                android:textSize="11sp"
                app:layout_constraintBottom_toBottomOf="@+id/btnWriteEM4305"
                app:layout_constraintRight_toLeftOf="@+id/btnWriteEM4305" />

            <Button
                android:id="@+id/btnWriteEM4305"
                android:layout_width="wrap_content"
                android:layout_height="40dp"
                android:onClick="write4305"
                android:text="写卡"
                android:textSize="11sp"
                app:layout_constraintBottom_toTopOf="@+id/editTextDataEM4305"
                app:layout_constraintRight_toRightOf="parent" />

            <TextView
                android:id="@+id/TextViewlabel11"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="数据速率:"
                android:textSize="12sp"
                app:layout_constraintBottom_toBottomOf="@+id/SpinnerDateRateEM4305"
                app:layout_constraintLeft_toLeftOf="parent"
                app:layout_constraintTop_toTopOf="@+id/SpinnerDateRateEM4305" />

            <Spinner
                android:id="@+id/SpinnerDateRateEM4305"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:entries="@array/datarateEM4305"
                android:spinnerMode="dropdown"
                android:theme="@style/my_spinner_style"
                app:layout_constraintLeft_toRightOf="@+id/TextViewlabel11"
                app:layout_constraintTop_toBottomOf="@+id/editTextDataEM4305">

            </Spinner>

            <TextView
                android:id="@+id/TextViewlabel12"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="调制模式:"
                android:textSize="12sp"
                app:layout_constraintBottom_toBottomOf="@+id/SpinnerDateRateEM4305"
                app:layout_constraintRight_toLeftOf="@+id/SpinnerEncoderEM4305"
                app:layout_constraintTop_toTopOf="@+id/SpinnerDateRateEM4305" />

            <Spinner
                android:id="@+id/SpinnerEncoderEM4305"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:entries="@array/EncoderEM4305"
                android:spinnerMode="dropdown"
                android:theme="@style/my_spinner_style"
                app:layout_constraintBottom_toBottomOf="@+id/SpinnerDateRateEM4305"
                app:layout_constraintRight_toRightOf="parent">

            </Spinner>

            <Spinner
                android:id="@+id/SpinnerLoginModeEM4305"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:entries="@array/loginmodeEM4305"
                android:spinnerMode="dropdown"
                android:theme="@style/my_spinner_style"
                app:layout_constraintLeft_toLeftOf="parent"
                app:layout_constraintRight_toRightOf="parent"
                app:layout_constraintTop_toBottomOf="@+id/SpinnerEncoderEM4305">

            </Spinner>


            <TextView
                android:id="@+id/TextViewlabel13"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="自动发送最大块:"
                android:textSize="12sp"
                app:layout_constraintBottom_toBottomOf="@+id/editTextMaxBlockEM4305"
                app:layout_constraintLeft_toLeftOf="parent"
                app:layout_constraintTop_toTopOf="@+id/editTextMaxBlockEM4305" />

            <EditText
                android:id="@+id/editTextMaxBlockEM4305"
                android:layout_width="25dp"
                android:layout_height="wrap_content"
                android:background="@drawable/shape4border"
                android:digits="0123456789"
                android:gravity="left"
                android:inputType="textCapCharacters"
                android:maxLength="2"
                android:paddingLeft="3dp"
                android:text="6"
                android:textSize="12sp"

                app:layout_constraintLeft_toRightOf="@+id/TextViewlabel13"
                app:layout_constraintTop_toBottomOf="@+id/SpinnerLoginModeEM4305" />

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="范围:5-13块,时序从5块至最大块"
                android:textSize="12sp"
                app:layout_constraintBottom_toBottomOf="@+id/editTextMaxBlockEM4305"
                app:layout_constraintLeft_toRightOf="@+id/editTextMaxBlockEM4305"
                app:layout_constraintTop_toTopOf="@+id/editTextMaxBlockEM4305" />



            <TextView
                android:id="@+id/TextViewlabel14"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="配置值:"
                android:textSize="12sp"
                app:layout_constraintBottom_toBottomOf="@+id/editTextConfigWordEM4305"
                app:layout_constraintLeft_toLeftOf="parent"
                app:layout_constraintTop_toTopOf="@+id/editTextConfigWordEM4305" />

            <EditText
                android:id="@+id/editTextConfigWordEM4305"
                android:layout_width="68dp"
                android:layout_height="wrap_content"
                android:layout_marginTop="5dp"
                android:background="@drawable/shape4border"
                android:digits="0123456789ABCDEFabcdef"
                android:gravity="left"
                android:inputType="textCapCharacters"
                android:maxLength="8"
                android:paddingLeft="3dp"
                android:text="5F800100"
                android:textSize="12sp"
                app:layout_constraintLeft_toRightOf="@+id/TextViewlabel14"
                app:layout_constraintTop_toBottomOf="@+id/editTextMaxBlockEM4305" />

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginLeft="10dp"
                android:text="(十六进制)"
                android:textSize="12sp"
                app:layout_constraintBottom_toBottomOf="@+id/editTextConfigWordEM4305"
                app:layout_constraintLeft_toRightOf="@+id/editTextConfigWordEM4305"
                app:layout_constraintTop_toTopOf="@+id/editTextConfigWordEM4305" />

            <Button
                android:id="@+id/btnDefalutEM4305"
                android:layout_width="wrap_content"
                android:layout_height="40dp"
                android:layout_marginRight="20dp"
                android:onClick="default4305"
                android:text="← 默认值"
                android:textSize="11sp"
                app:layout_constraintBottom_toBottomOf="@+id/btnInitEM4305"
                app:layout_constraintRight_toLeftOf="@+id/btnInitEM4305" />


            <Button
                android:id="@+id/btnInitEM4305"
                android:layout_width="wrap_content"
                android:layout_height="40dp"
                android:onClick="init4305"
                android:text="设定配置"
                android:textSize="12sp"
                app:layout_constraintRight_toRightOf="parent"
                app:layout_constraintTop_toBottomOf="@+id/TextViewlabel14" />

        </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.AdapterView;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.Spinner;
import android.widget.TextView;

import com.reader.ouridr;
import com.reader.ourmifare;
public class EM4305Activity extends AppCompatActivity {
    private TextView tv;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_em4305);
        androidx.appcompat.widget.Toolbar toolbar=findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);

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

        //增加输入监听事件
        // EM4305
        ((EditText)findViewById(R.id.editTextMaxBlockEM4305)).setOnFocusChangeListener(new View.OnFocusChangeListener(){

            @Override
            public void onFocusChange(View v,boolean FocusState) {
                if(FocusState){//进入焦点

                }
                else{//离开焦点
                    updateset4305();
                }

            }
        });

        //数据速率
        Spinner spls;
        spls = findViewById(R.id.SpinnerDateRateEM4305);
        spls.setSelection(2);//RF/16

        spls.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
            @Override
            public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
                updateset4305();
            }

            @Override
            public void onNothingSelected(AdapterView<?> parent) {

            }
        });


        //调制模式
        ((Spinner)findViewById(R.id.SpinnerEncoderEM4305)).setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
            @Override
            public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
                updateset4305();
            }

            @Override
            public void onNothingSelected(AdapterView<?> parent) {

            }
        });

        //加密模式
        ((Spinner)findViewById(R.id.SpinnerLoginModeEM4305)).setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
            @Override
            public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
                updateset4305();
            }

            @Override
            public void onNothingSelected(AdapterView<?> parent) {

            }
        });
    }
    @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 textclear4305(View view)
    {
        TextView tvls;
        tvls = findViewById(R.id.TextViewRetDataEM4305);
        tvls.setText("");
    }
    public void changepwd4305(View view)
    {
        byte i;
        byte j;
        byte status;//存放返回值

        byte myctrlword;//控制字

        byte[] oldpicckey = new byte[4];//旧密码
        byte[] mypiccserial = new byte[4];//卡序列号
        byte[] newpicckey = new byte[4];//新密码

        myctrlword = 0; //NEEDSERIAL:需要只对指定系列号的卡操作,NEEDKEY:需要用密码认证,LOCKBIT:锁定块,KEYENABLE:启用本卡的密码功能

        String strls;

        CheckBox cbls;
        EditText etls;

        cbls = findViewById(R.id.chkPwdEM4305);
        if(!cbls.isChecked()) {//本次操作需要密码验证
            tv.setText("EM4305卡修改卡密码必须带密码操作");
            return;
        }

        etls = findViewById(R.id.editTextPwdEM4305);
        strls = etls.getText().toString().trim();
        if(strls.length() < 8)
        {
            tv.setText("旧密码长度不足8位");
            return;
        }
        for (i = 0; i < 4; i++) {
            oldpicckey[i] = (byte)Integer.parseInt(strls.substring(i*2,i*2+2),16);//只有用Integer.parseInt才能杜绝大于128时的错误
        }
        myctrlword += ouridr.NEEDKEY;

        cbls = findViewById(R.id.chkUidNeedEM4305);
        if(cbls.isChecked()) {//仅操作指定卡号的卡
            etls = findViewById(R.id.editTextUidEM4305);
            strls = etls.getText().toString().trim();
            if(strls.length() < 8)
            {
                tv.setText("卡号长度不足8位");
                return;
            }

            for (i = 0; i < 4; i++) {
                mypiccserial[i] = (byte)Integer.parseInt(strls.substring(i*2,i*2+2),16);//只有用Integer.parseInt才能杜绝大于128时的错误
            }
            myctrlword += ouridr.NEEDSERIAL;

        }

        etls = findViewById(R.id.editTextPwdNewEM4305);
        strls = etls.getText().toString().trim();
        if(strls.length() < 8)
        {
            tv.setText("新密码长度不足8位!");
            return;
        }

        for (i = 0; i < 4; i++) {
            newpicckey[i] = (byte)Integer.parseInt(strls.substring(i*2,i*2+2),16);//只有用Integer.parseInt才能杜绝大于128时的错误
        }

        status = ouridr.em4305changekey(myctrlword,mypiccserial,oldpicckey,newpicckey);

        if(status == 0)
        {

            strls = "卡号[";

            strls += String.format("%02X%02X%02X%02X",mypiccserial[0],mypiccserial[1],mypiccserial[2],mypiccserial[3]);

            strls += "]";

            TextView tvls = findViewById(R.id.TextViewRetDataEM4305);
            tvls.setText(strls);

            strls = "EM4305卡修改卡密码成功";

            ouridr.beep(38);



        }
        else
        {

            if(status == 8)
            {
                strls = "请将卡放在感应区";
            }
            else if(status == 23)
            {
                strls = "错误代码:23,读卡器未插入";
            }
            else if(status == 1)
            {
                strls = "错误代码:1,卡放得远 或 需要密码才能写卡";
            }
            else if(status == 12)
            {
                strls = "错误代码:12,卡放得远 或 密码错误";
            }
            else
            {
                strls = "错误代码:" + Integer.toString(status);
            }

        }

        tv.setText(strls);
    }
    public void read4305(View view)
    {
        byte i;
        byte status;//存放返回值

        byte myctrlword;//控制字

        byte[] oldpicckey = new byte[4];//密码
        byte[] mypiccserial = new byte[4];//卡序列号
        byte[] mypiccdata = new byte[64];//读卡数据缓冲:卡无线转输分频比、卡内容长度(字节数),及最多返回12块的数据
        byte[] mypiccblockflag = new byte[2];//指定读哪一块

        myctrlword = 0; //NEEDSERIAL:需要只对指定系列号的卡操作,NEEDKEY:需要用密码认证,LOCKBIT:锁定块,KEYENABLE:启用本卡的密码功能

        String strls;

        CheckBox cbls;
        EditText etls;

        cbls = findViewById(R.id.chkPwdEM4305);
        if(cbls.isChecked()) {//本次操作需要密码验证
            etls = findViewById(R.id.editTextPwdEM4305);
            strls = etls.getText().toString().trim();
            if(strls.length() < 8)
            {
                tv.setText("密码长度不足8位");
                return;
            }
            for (i = 0; i < 4; i++) {
                oldpicckey[i] = (byte)Integer.parseInt(strls.substring(i*2,i*2+2),16);//只有用Integer.parseInt才能杜绝大于128时的错误
            }
            myctrlword += ouridr.NEEDKEY;

        }

        cbls = findViewById(R.id.chkUidNeedEM4305);
        if(cbls.isChecked()) {//仅操作指定卡号的卡
            etls = findViewById(R.id.editTextUidEM4305);
            strls = etls.getText().toString().trim();
            if(strls.length() < 8)
            {
                tv.setText("卡号长度不足8位");
                return;
            }

            for (i = 0; i < 4; i++) {
                mypiccserial[i] = (byte)Integer.parseInt(strls.substring(i*2,i*2+2),16);//只有用Integer.parseInt才能杜绝大于128时的错误
            }
            myctrlword += ouridr.NEEDSERIAL;

        }

        //操作块标志
        mypiccblockflag[0] = 0;

        cbls = findViewById(R.id.chkB0EM4305);
        if(cbls.isChecked()) {
            mypiccblockflag[0] += 1;
        }

        cbls = findViewById(R.id.chkB1EM4305);
        if(cbls.isChecked()) {
            mypiccblockflag[0] += 2;
        }

        cbls = findViewById(R.id.chkB3EM4305);
        if(cbls.isChecked()) {
            mypiccblockflag[0] += 8;
        }

        cbls = findViewById(R.id.chkB4EM4305);
        if(cbls.isChecked()) {
            mypiccblockflag[0] += 16;
        }

        cbls = findViewById(R.id.chkB5EM4305);
        if(cbls.isChecked()) {
            mypiccblockflag[0] += 32;
        }

        cbls = findViewById(R.id.chkB6EM4305);
        if(cbls.isChecked()) {
            mypiccblockflag[0] += 64;
        }

        cbls = findViewById(R.id.chkB7EM4305);
        if(cbls.isChecked()) {
            mypiccblockflag[0] += 128;
        }

        mypiccblockflag[1] = 0;

        cbls = findViewById(R.id.chkB8EM4305);
        if(cbls.isChecked()) {
            mypiccblockflag[1] += 1;
        }

        cbls = findViewById(R.id.chkB9EM4305);
        if(cbls.isChecked()) {
            mypiccblockflag[1] += 2;
        }

        cbls = findViewById(R.id.chkB10EM4305);
        if(cbls.isChecked()) {
            mypiccblockflag[1] += 4;
        }

        cbls = findViewById(R.id.chkB11EM4305);
        if(cbls.isChecked()) {
            mypiccblockflag[1] += 8;
        }

        cbls = findViewById(R.id.chkB12EM4305);
        if(cbls.isChecked()) {
            mypiccblockflag[1] += 16;
        }

        cbls = findViewById(R.id.chkB13EM4305);
        if(cbls.isChecked()) {
            mypiccblockflag[1] += 32;
        }

        cbls = findViewById(R.id.chkB14EM4305);
        if(cbls.isChecked()) {
            mypiccblockflag[1] += 64;
        }

        cbls = findViewById(R.id.chkB15EM4305);
        if(cbls.isChecked()) {
            mypiccblockflag[1] += 128;
        }

        status = ouridr.em4305read(myctrlword,mypiccserial,oldpicckey,mypiccblockflag,mypiccdata);

        if(status == 0)
        {

            strls = "卡无线转输分频比[" + Integer.toString(mypiccdata[0]) + "],卡号[";

            strls += String.format("%02X%02X%02X%02X",mypiccserial[0],mypiccserial[1],mypiccserial[2],mypiccserial[3]);

            strls += "],卡数据[";

            for (i = 0; i < mypiccdata[1]; i++) {
                strls += String.format("%02X",mypiccdata[i+2]);
            }

            strls += "]";

            TextView tvls = findViewById(R.id.TextViewRetDataEM4305);
            tvls.setText(strls);

            strls = "读EM4305卡成功";

            ouridr.beep(38);



        }
        else
        {

            if(status == 8)
            {
                strls = "请将卡放在感应区";
            }
            else if(status == 23)
            {
                strls = "错误代码:23,读卡器未插入";
            }
            else if(status == 4)
            {
                strls = "错误代码:4,卡放得远 或 需要密码才能读卡";
            }
            else if(status == 12)
            {
                strls = "错误代码:12,卡放得远 或 密码错误";
            }
            else
            {
                strls = "错误代码:" + Integer.toString(status);
            }

        }

        tv.setText(strls);
    }
    public void write4305(View view)
    {
        byte i;
        byte j;
        byte status;//存放返回值

        byte myctrlword;//控制字

        byte[] oldpicckey = new byte[4];//密码
        byte[] mypiccserial = new byte[4];//卡序列号
        byte[] mypiccdata = new byte[64];//读卡数据缓冲:卡无线转输分频比、卡内容长度(字节数),最多12块的数据
        byte[] mypiccblockflag = new byte[2];//指定读哪一块

        myctrlword = 0; //NEEDSERIAL:需要只对指定系列号的卡操作,NEEDKEY:需要用密码认证,LOCKBIT:锁定块,KEYENABLE:启用本卡的密码功能

        String strls;

        CheckBox cbls;
        EditText etls;

        cbls = findViewById(R.id.chkPwdEM4305);
        if(cbls.isChecked()) {//本次操作需要密码验证
            etls = findViewById(R.id.editTextPwdEM4305);
            strls = etls.getText().toString().trim();
            if(strls.length() < 8)
            {
                tv.setText("密码长度不足8位");
                return;
            }
            for (i = 0; i < 4; i++) {
                oldpicckey[i] = (byte)Integer.parseInt(strls.substring(i*2,i*2+2),16);//只有用Integer.parseInt才能杜绝大于128时的错误
            }
            myctrlword += ouridr.NEEDKEY;

        }

        cbls = findViewById(R.id.chkUidNeedEM4305);
        if(cbls.isChecked()) {//仅操作指定卡号的卡
            etls = findViewById(R.id.editTextUidEM4305);
            strls = etls.getText().toString().trim();
            if(strls.length() < 8)
            {
                tv.setText("卡号长度不足8位");
                return;
            }

            for (i = 0; i < 4; i++) {
                mypiccserial[i] = (byte)Integer.parseInt(strls.substring(i*2,i*2+2),16);//只有用Integer.parseInt才能杜绝大于128时的错误
            }
            myctrlword += ouridr.NEEDSERIAL;

        }

        //操作块标志
        j = 0;
        mypiccblockflag[0] = 0;

        cbls = findViewById(R.id.chkB0EM4305);
        if(cbls.isChecked()) {
            mypiccblockflag[0] += 1;
            j++;
        }

        cbls = findViewById(R.id.chkB1EM4305);
        if(cbls.isChecked()) {
            tv.setText("块1为只读,不允许写");
            return;
        }

        cbls = findViewById(R.id.chkB3EM4305);
        if(cbls.isChecked()) {
            mypiccblockflag[0] += 8;
            j++;
        }

        cbls = findViewById(R.id.chkB4EM4305);
        if(cbls.isChecked()) {
            tv.setText("块4为配置区,只能在初始化函数中操作");
            return;
        }

        cbls = findViewById(R.id.chkB5EM4305);
        if(cbls.isChecked()) {
            mypiccblockflag[0] += 32;
            j++;
        }

        cbls = findViewById(R.id.chkB6EM4305);
        if(cbls.isChecked()) {
            mypiccblockflag[0] += 64;
            j++;
        }

        cbls = findViewById(R.id.chkB7EM4305);
        if(cbls.isChecked()) {
            mypiccblockflag[0] += 128;
            j++;
        }

        mypiccblockflag[1] = 0;

        cbls = findViewById(R.id.chkB8EM4305);
        if(cbls.isChecked()) {
            mypiccblockflag[1] += 1;
            j++;
        }

        cbls = findViewById(R.id.chkB9EM4305);
        if(cbls.isChecked()) {
            mypiccblockflag[1] += 2;
            j++;
        }

        cbls = findViewById(R.id.chkB10EM4305);
        if(cbls.isChecked()) {
            mypiccblockflag[1] += 4;
            j++;
        }

        cbls = findViewById(R.id.chkB11EM4305);
        if(cbls.isChecked()) {
            mypiccblockflag[1] += 8;
            j++;
        }

        cbls = findViewById(R.id.chkB12EM4305);
        if(cbls.isChecked()) {
            mypiccblockflag[1] += 16;
            j++;
        }

        cbls = findViewById(R.id.chkB13EM4305);
        if(cbls.isChecked()) {
            mypiccblockflag[1] += 32;
            j++;
        }

        cbls = findViewById(R.id.chkB14EM4305);
        if(cbls.isChecked()) {
            tv.setText("块14为锁定标志块,只能在初始化函数中操作");
            return;
        }

        cbls = findViewById(R.id.chkB15EM4305);
        if(cbls.isChecked()) {
            tv.setText("块15为锁定标志块,只能在初始化函数中操作");
            return;
        }

        //写卡数据准备
        if(j == 0)
        {
            tv.setText("请先选择需要写入的块");
            return;
        }
        etls = findViewById(R.id.editTextDataEM4305);
        strls = etls.getText().toString().trim();
        if(strls.length() < (j*8))
        {
            tv.setText("写入数据长度不足,请补足数据!");
            return;
        }

        for (i = 0; i < (j*4); i++) {
            mypiccdata[i] = (byte)Integer.parseInt(strls.substring(i*2,i*2+2),16);//只有用Integer.parseInt才能杜绝大于128时的错误
        }

        status = ouridr.em4305write(myctrlword,mypiccserial,oldpicckey,mypiccblockflag,mypiccdata);

        if(status == 0)
        {

            strls = "卡号[";

            strls += String.format("%02X%02X%02X%02X",mypiccserial[0],mypiccserial[1],mypiccserial[2],mypiccserial[3]);

            strls += "]";

            TextView tvls = findViewById(R.id.TextViewRetDataEM4305);
            tvls.setText(strls);

            strls = "写EM4305卡成功";

            ouridr.beep(38);



        }
        else
        {

            if(status == 8)
            {
                strls = "请将卡放在感应区";
            }
            else if(status == 23)
            {
                strls = "错误代码:23,读卡器未插入";
            }
            else if(status == 1)
            {
                strls = "错误代码:1,卡放得远 或 需要密码才能写卡";
            }
            else if(status == 12)
            {
                strls = "错误代码:12,卡放得远 或 密码错误";
            }
            else
            {
                strls = "错误代码:" + Integer.toString(status);
            }

        }

        tv.setText(strls);
    }
    public void default4305(View view)
    {
        EditText etls;
        Spinner spls;

        etls = findViewById(R.id.editTextConfigWordEM4305);
        etls.setText("5F800100");
        etls = findViewById(R.id.editTextMaxBlockEM4305);
        etls.setText("6");

        spls = findViewById(R.id.SpinnerDateRateEM4305);//数据速率
        spls.setSelection(2);
        spls = findViewById(R.id.SpinnerEncoderEM4305);//调制模式
        spls.setSelection(0);
        spls = findViewById(R.id.SpinnerLoginModeEM4305);//加密模式
        spls.setSelection(0);
    }

    public void updateset4305()
    {
        EditText etls;
        EditText etMaxBlock;
        Spinner spls;
        String strls;
        byte i;

        byte[] Configdata = new byte[4];//配置值

        etls = findViewById(R.id.editTextConfigWordEM4305);
        strls = etls.getText().toString().trim();
        if(strls.length() < 8){
            strls = "5F800100";
            Configdata[0] = 0x5F;
            Configdata[1] = (byte)0x80;
            Configdata[2] = 0x01;
            Configdata[3] = 0x00;
        }
        else {
            for (i = 1; i < 4; i++) {
                Configdata[i] = (byte)Integer.parseInt(strls.substring(i * 2, i * 2 + 2),16);//只有用Integer.parseInt才能杜绝大于128时的错误
            }
        }

        spls = findViewById(R.id.SpinnerDateRateEM4305);//数据速率
        i = (byte)(spls.getSelectedItemId());
        Configdata[0] = 0x00;

        if(i == 0){//RF/32
            Configdata[0] |= 0x0f;
        }
        else if(i == 1) {//RF/40
            Configdata[0] |= 0x13;
        }
        else {//RF/64或其他
            Configdata[0] |= 0x1f;
        }

        spls = findViewById(R.id.SpinnerEncoderEM4305);//调制模式
        i = (byte)(spls.getSelectedItemId());
        if(i == 0){//曼切斯特码
            Configdata[0] |= 0x40;
        }
        else if(i == 1) {//Biphase码
            Configdata[0] |= 0x80;
        }
        else {//其他

        }

        Configdata[1] &= 0x3c;
        Configdata[2] &= 0x80;
        //自动发送最大块
        etMaxBlock = findViewById(R.id.editTextMaxBlockEM4305);
        strls = etMaxBlock.getText().toString().trim();
        if(strls.length() < 1){
            i = 6;
            etMaxBlock.setText("6");
        }
        else {
            i = (byte)Integer.parseInt(strls,10);
            if((i < 5) || (i > 13)){
                i = 6;
                etMaxBlock.setText("6");
            }
        }

        Configdata[1] |=  ((i % 4) * 64);
        Configdata[2] |= ((i / 4) % 4);

        spls = findViewById(R.id.SpinnerLoginModeEM4305);//密码规则(也就是读登陆或写登陆)
        i = (byte)(spls.getSelectedItemId());
        if(i == 1){//0-1块任意读,3-15块需密码读,0-13块任意写,14-15块需密码写
            i = 0x01;
        }
        else if(i == 2) {//0-15任意读,0-15块需密码写
            i = 0x04;
        }
        else if(i == 3) {//0-1块任意读,3-15块需密码读,0-15块需密码写
            i = 0x05;
        }
        else {//0-15块任意读.0-13块任意写,14-15块需密码写
            i = 0x00;
        }

        Configdata[2] |= (i * 4);

        etls.setText(String.format("%02X%02X%02X%02X",Configdata[0],Configdata[1],Configdata[2],Configdata[3]));

    }
    public void init4305(View view)
    {
        byte i;
        byte status;//存放返回值

        byte myctrlword;//控制字

        byte[] oldpicckey = new byte[4];//密码
        byte[] mypiccserial = new byte[4];//卡序列号
        byte[] mypiccdata = new byte[4];//写入数据缓冲

        myctrlword = 0; //NEEDSERIAL:需要只对指定系列号的卡操作,NEEDKEY:需要用密码认证,LOCKBIT:锁定块,KEYENABLE:启用本卡的密码功能

        String strls;

        CheckBox cbls;
        EditText etls;

        updateset4305();

        cbls = findViewById(R.id.chkPwdEM4305);
        if(cbls.isChecked()) {//本次操作需要密码验证
            etls = findViewById(R.id.editTextPwdEM4305);
            strls = etls.getText().toString().trim();
            if(strls.length() < 8)
            {
                tv.setText("密码长度不足8位");
                return;
            }
            for (i = 0; i < 4; i++) {
                oldpicckey[i] = (byte)Integer.parseInt(strls.substring(i*2,i*2+2),16);//只有用Integer.parseInt才能杜绝大于128时的错误
            }
            myctrlword += ouridr.NEEDKEY;

        }


        cbls = findViewById(R.id.chkUidNeedEM4305);
        if(cbls.isChecked()) {//仅操作指定卡号的卡
            etls = findViewById(R.id.editTextUidEM4305);
            strls = etls.getText().toString().trim();
            if(strls.length() < 8)
            {
                tv.setText("卡号长度不足8位");
                return;
            }

            for (i = 0; i < 4; i++) {
                mypiccserial[i] = (byte)Integer.parseInt(strls.substring(i*2,i*2+2),16);//只有用Integer.parseInt才能杜绝大于128时的错误
            }
            myctrlword += ouridr.NEEDSERIAL;

        }

        //配置值:
        etls = findViewById(R.id.editTextConfigWordEM4305);
        strls = etls.getText().toString().trim();
        if(strls.length() < 8)
        {
            tv.setText("配置值输入长度不足8位");
            return;
        }
        for (i = 0; i < 4; i++) {
            mypiccdata[i] = (byte)Integer.parseInt(strls.substring(i*2,i*2+2),16);//只有用Integer.parseInt才能杜绝大于128时的错误
        }

        status = ouridr.em4305init(myctrlword,mypiccserial,oldpicckey,mypiccdata);

        if(status == 0)
        {

            strls = "卡号[";

            strls += String.format("%02X%02X%02X%02X",mypiccserial[0],mypiccserial[1],mypiccserial[2],mypiccserial[3]);

            strls += "]";

            TextView tvls = findViewById(R.id.TextViewRetDataEM4305);
            tvls.setText(strls);

            strls = "配置EM4305卡成功";

            ouridr.beep(38);

        }
        else
        {

            if(status == 8)
            {
                strls = "卡不在感应区 或 密码不正确";
            }
            else if(status == 23)
            {
                strls = "错误代码:23,读卡器未插入";
            }
            else if(status == 1)
            {
                strls = "错误代码:1,卡放得远 或 需要密码才能写卡";
            }
            else if(status == 12)
            {
                strls = "错误代码:12,卡放得远 或 密码错误";
            }
            else
            {
                strls = "错误代码:" + Integer.toString(status);
            }

        }

        tv.setText(strls);
    }

}

源码下载:AndroidstudioRFIDNFC读写源码资源-CSDN文库

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

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

相关文章

蓝桥杯备赛 day 2 —— 二分算法(C/C++,零基础,配图)

目录 &#x1f308;前言&#xff1a; &#x1f4c1; 二分的概念 &#x1f4c1; 整数二分 &#x1f4c1; 二分的模板 &#x1f4c1; 习题 &#x1f4c1; 总结 &#x1f308;前言&#xff1a; 这篇文章主要是准备蓝桥杯竞赛同学所写&#xff0c;为你更好准备蓝桥杯比赛涉及…

【音视频原理】图像相关概念 ② ( 帧率 | 常见帧率标准 | 码率 | 码率单位 )

文章目录 一、帧率1、帧率简介2、常见帧率标准3、帧率 刷新率 二、码率1、码率简介2、码率单位 一、帧率 1、帧率简介 帧率 Frame Rate , 帧 指的是 是 画面帧 , 帧率 是 画面帧 的 速率 ; 帧率 的 单位是 FPS , Frames Per Second , 是 每秒钟 的 画面帧 个数 ; 帧率 是 动画…

弗洛伊德循环查找算法-原理

本文灵感来自哔哩哔哩视频 视频链接: 弗洛伊德循环查找算法 算法代码(java) package rain;class ListNode {int value;ListNode next;public ListNode(int value) {this.value value;this.next null;}Overridepublic String toString() {return "ListNode{" &q…

Kotlin 移动端多平台

支持多平台编程是 Kotlin 的主要优势之一。它减少了为不同平台编写和维护相同代码所花费的时间&#xff0c;同时保留了本机编程的灵活性和优势。 1. 基本概念 KMM&#xff1a;Kotlin Multiplatform for mobile&#xff08;移动设备的 Kotlin 多平台&#xff09; KMM 多平台的主…

使用的uview 微信高版本 头像昵称填写能力

<template><view><button class"cu-btn block bg-blue margin-tb-sm lg" tap"wxGetUserInfo">一键登录</button><view><!-- 提示窗示例 --><u-popup :show"show" background-color"#fff">&…

pygame里实现导弹追踪效果,同时对python的指针机制有一点点思考

最近,儿子一直缠着让我把之前给他编写的游戏重做一下,要加一些功能.但是因为之前写代码的时候刚学会python,当时的想法就是能跑就行,现在回头看来,代码的可维护性几乎为零.所以没办法只能冲头再来,重构了几乎所有代码.在编写的时候遇到了一个有意思的问题,儿子让我给游戏添加一…

Pyside6入门教学——编写一个UI界面并显示

1、安装Pyside6 输入下列命令安装Pyside6。 pip install Pyside6 2、设计UI 打开Qt设计工具&#xff08;在安装Pyside6包的目录下&#xff09;。 【注】我这用的是anaconda虚拟环境&#xff0c;所以我的路径是D:\App\Anaconda3\envs\snake\Lib\site-packages\PySide6。设计…

【Python学习】Python学习19- 异常处理

目录 【Python学习】Python学习19- 异常处理 前言python标准异常异常处理带异常类型语法不带异常类型语法使用except而带多种异常类型try-finally 语句触发异常 参考 文章所属专区 Python学习 前言 本章节主要说明Python的异常处理。 python标准异常 BaseException 所有异常…

GNU Radio简介及流程图搭建

文章目录 前言一、GNU Radio 是什么&#xff1f;二、GNU Radio 安装三、搭建第一个流程图1、创建 GRC 文件2、添加块3、运行流程图 前言 欢迎来到无线通信的世界&#xff0c;初步接触 GNU Radio&#xff0c;对其学习进行一个记录。 一、GNU Radio 是什么&#xff1f; GNU Rad…

【C语言编程之旅 4】刷题篇-关键字

第一题 解析 C语言关键字&#xff1a;C语言定义的&#xff0c;具有特定含义、专门用于特殊用途的C语言标识符&#xff0c;也称为保留字 A&#xff1a;错误&#xff0c;关键字是语言自身定义的 B&#xff1a;正确 C&#xff1a;错误&#xff0c;关键字具有特殊含义&#xff…

docker部署项目,/var/lib/docker/overlay2目录满了如何清理?

docker部署项目&#xff0c;/var/lib/docker/overlay2目录满了如何清理&#xff1f; 一、问题二、解决1、查看 /var/lib/docker 目录&#xff08;1&#xff09;、containers 目录&#xff08;2&#xff09;、volumes 目录&#xff08;3&#xff09;、overlay2 目录 2、清理&…

Java开发分析 JProfiler 14 中文

JProfiler 14是一款强大的Java分析工具&#xff0c;专为帮助Java开发者优化应用性能而设计。它提供了实时监控、内存分析、线程分析、CPU分析等多种功能&#xff0c;帮助开发者快速定位和解决性能问题。JProfiler 14具有直观的用户界面&#xff0c;使用户能够轻松上手。此外&am…

苹果Find My可查找添加32件物品,伦茨科技ST17H6x芯片加速产品赋能

苹果最近更新的支持文档证实&#xff0c;从 iOS 16 开始&#xff0c;"Find My"可查找添加物品从16件增加到32件&#xff0c;AirTag 和“查找”网络中的物品利用“查找”网络的强大功能来发挥作用&#xff0c;这个网络由数亿台加密的匿名 Apple 设备构成。“查找”网络…

Kafka-多线程消费及分区设置

目录 一、Kafka是什么&#xff1f;消息系统&#xff1a;Publish/subscribe&#xff08;发布/订阅者&#xff09;模式相关术语 二、初步使用1.yml文件配置2.生产者类3.消费者类4.发送消息 三、减少分区数量1.停止业务服务进程2.停止kafka服务进程3.重新启动kafka服务4.重新启动业…

PPT大神带你飞!!!

1、OneKeyTools 官网&#xff1a;http://oktools.xyz/ OneKeyTools是一款免费开源的PowerPoint第三方平面设计辅助插件&#xff0c;功能涵盖了形状、调色、三维、图片处理、辅助功能等等方面。 插件功能&#xff1a; 插件从面世逐步受到广大PPT设计师和爱好者的追捧&#x…

感谢大家的支持,继续耕耘

有什么大家感兴趣的领域&#xff0c;欢迎留言

SSH数据流量监控

简介 检查网络连接的数据传输情况有以下一些实际意义&#xff1a; 安全监控&#xff1a;检查数据传输情况可以帮助你识别异常活动或潜在的安全威胁。如果发现大量不寻常的数据传输活动&#xff0c;可能表示有未经授权的访问或恶意行为。通过监控数据传输&#xff0c;可以及时发…

软件测评中心▏正式验收测试和非正式验收的优缺点简析

软件正式验收测试需要非常严格的管理&#xff0c;是对系统测试的延续&#xff0c;这种验收测试的测试用例应是系统测试的子集。非正式验收测试不像正式验收测试那么严格&#xff0c;不需要执行指定的测试用例&#xff0c;可以由测试人员自主决定&#xff0c;但制定测试用例时必…

node.js(express.js)+mysql实现登录功能

文章目录 前言实现步骤 实现步骤一、检测登录表单的数据是否合法&#xff08;3&#xff09;新建schema/user.js&#xff08;4&#xff09;在routes/use.js中引入schema/user.js中的方法reg_login_schema&#xff0c;代码如下&#xff1a; 二、根据用户名查询用户的数据三、判断…

浅析Redis①:命令处理核心源码分析(上)

写在前面 Redis作为我们日常工作中最常使用的缓存数据库&#xff0c;其重要性不言而喻&#xff0c;作为普调开发者&#xff0c;我们在日常开发中使用Redis&#xff0c;主要聚焦于Redis的基层数据结构的命令使用&#xff0c;很少会有人对Redis的内部实现机制进行了解&#xff0c…