Android Studio读写低频RFID T5557卡源码

news2024/9/28 13:26:42

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

<?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=".T5557Activity">
    <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="T5557卡测试页  "
            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/chkPwdT5557"
                android:layout_width="wrap_content"
                android:layout_height="30dp"
                android:layout_marginLeft="2dp"
                android:textSize="12sp"
                android:checked="false"
                android:text="带密码操作"
                app:layout_constraintLeft_toLeftOf="parent"
                app:layout_constraintTop_toTopOf="parent"/>

            <EditText
                android:id="@+id/editTextPwdT5557"
                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/chkPwdT5557"
                app:layout_constraintLeft_toRightOf="@+id/chkPwdT5557"
                app:layout_constraintTop_toTopOf="@+id/chkPwdT5557"

                />

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



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

            <EditText
                android:id="@+id/editTextUidT5557"
                android:layout_width="110dp"
                android:layout_height="wrap_content"
                android:layout_marginLeft="10dp"
                android:background="@drawable/shape4border"
                android:digits="0123456789ABCDEFabcdef"
                android:gravity="center"
                android:inputType="textCapCharacters"
                android:maxLength="12"
                android:maxLines="1"
                android:text="000000000000"
                android:textSize="14sp"
                app:layout_constraintBottom_toBottomOf="@+id/chkUidNeedT5557"
                app:layout_constraintLeft_toRightOf="@+id/chkUidNeedT5557"
                app:layout_constraintTop_toTopOf="@+id/chkUidNeedT5557" />



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

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

                />

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

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

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

                />

            <EditText
                android:id="@+id/editTextPwdNewT5557"
                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/btnPwdChangeT5557"
                app:layout_constraintLeft_toRightOf="@+id/TextViewlabel1"
                app:layout_constraintTop_toTopOf="@+id/btnPwdChangeT5557" />

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


            <TextView
                android:id="@+id/TextViewlabel2"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="第0页:"
                android:textSize="12sp"
                app:layout_constraintLeft_toLeftOf="parent"
                app:layout_constraintTop_toTopOf="@+id/chkB0T5557"
                app:layout_constraintBottom_toBottomOf="@+id/chkB0T5557"
                />

            <CheckBox
                android:id="@+id/chkB0T5557"
                android:layout_width="wrap_content"
                android:layout_height="30dp"
                android:layout_marginLeft="2dp"
                android:textSize="11sp"
                android:checked="false"
                android:text="块0"
                app:layout_constraintLeft_toRightOf="@+id/TextViewlabel2"
                app:layout_constraintTop_toBottomOf="@+id/btnPwdChangeT5557"/>

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

            <CheckBox
                android:id="@+id/chkB3T5557"
                android:layout_width="wrap_content"
                android:layout_height="30dp"
                android:layout_marginLeft="2dp"
                android:textSize="11sp"
                android:checked="false"
                android:text="块3"
                app:layout_constraintLeft_toRightOf="@+id/chkB2T5557"
                app:layout_constraintBottom_toBottomOf="@+id/chkB0T5557"/>
            <CheckBox
                android:id="@+id/chkB4T5557"
                android:layout_width="wrap_content"
                android:layout_height="30dp"
                android:layout_marginLeft="2dp"
                android:textSize="12sp"
                android:checked="false"
                android:text="块4"
                app:layout_constraintLeft_toRightOf="@+id/chkB3T5557"
                app:layout_constraintBottom_toBottomOf="@+id/chkB0T5557"/>
            <CheckBox
                android:id="@+id/chkB5T5557"
                android:layout_width="wrap_content"
                android:layout_height="30dp"
                android:layout_marginLeft="2dp"
                android:textSize="12sp"
                android:checked="false"
                android:text="块5"
                app:layout_constraintLeft_toRightOf="@+id/chkB4T5557"
                app:layout_constraintBottom_toBottomOf="@+id/chkB0T5557"/>

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

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

            <TextView
                android:id="@+id/TextViewlabel3"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="第1页:"
                android:textSize="12sp"
                android:layout_marginLeft="20dp"
                app:layout_constraintLeft_toRightOf="@+id/chkB7T5557"
                app:layout_constraintTop_toTopOf="@+id/chkB7T5557"
                app:layout_constraintBottom_toBottomOf="@+id/chkB7T5557"
                />

            <CheckBox
                android:id="@+id/chkB11T5557"
                android:layout_width="wrap_content"
                android:layout_height="30dp"
                android:checked="false"
                android:text="块1"
                android:textSize="11sp"
                app:layout_constraintBottom_toBottomOf="@+id/chkB7T5557"
                app:layout_constraintLeft_toRightOf="@+id/TextViewlabel3" />

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

            <CheckBox
                android:id="@+id/chkB13T5557"
                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/chkB7T5557"
                app:layout_constraintLeft_toRightOf="@+id/chkB12T5557" />

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

            <Button
                android:id="@+id/btnReadT5557"
                android:layout_width="wrap_content"
                android:layout_height="40dp"
                android:layout_marginRight="20dp"
                android:onClick="read5557"
                android:text="读卡"
                android:textSize="11sp"
                app:layout_constraintRight_toLeftOf="@+id/btnWriteT5557"
                app:layout_constraintTop_toBottomOf="@+id/chkB7T5557" />

            <Button
                android:id="@+id/btnWriteT5557"
                android:layout_width="wrap_content"
                android:layout_height="40dp"
                android:onClick="write5557"
                android:text="写卡"
                android:textSize="11sp"
                app:layout_constraintRight_toRightOf="parent"
                app:layout_constraintTop_toBottomOf="@+id/chkB7T5557" />

            <TextView
                android:id="@+id/TextViewlabel4"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="写入数据:"
                android:textSize="12sp"
                app:layout_constraintBottom_toBottomOf="@+id/btnReadT5557"
                app:layout_constraintLeft_toLeftOf="parent" />

            <EditText
                android:id="@+id/editTextDataT5557"
                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:text="11111111"
                android:padding="3dp"
                android:textSize="12sp"
                app:layout_constraintLeft_toLeftOf="@+id/TextViewRetDataT5557"
                app:layout_constraintRight_toRightOf="@+id/TextViewRetDataT5557"
                app:layout_constraintTop_toBottomOf="@+id/btnWriteT5557" />

            <TextView
                android:id="@+id/TextViewlabel5"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="配置区位于第0页第0块:\ne5550兼容模式,主控键值默认(不等于6及不等于9),波特率RF/32,调制模式为\n曼彻斯特码,相位键控RF/2,自动发送最大块为1,卡片复位无延时\n如需改动以上值请联系我们 !"
                android:textSize="12sp"
                app:layout_constraintTop_toBottomOf="@+id/editTextDataT5557"
                app:layout_constraintLeft_toLeftOf="parent" />

            <CheckBox
                android:id="@+id/chkAOR"
                android:layout_width="wrap_content"
                android:layout_height="30dp"
                android:layout_marginLeft="2dp"
                android:textSize="12sp"
                android:checked="false"
                android:text="AOR请求应答模式"
                android:onClick="updateset5557"
                app:layout_constraintLeft_toLeftOf="parent"
                app:layout_constraintTop_toBottomOf="@+id/TextViewlabel5"/>

            <CheckBox
                android:id="@+id/chkFrameEnd"
                android:layout_width="wrap_content"
                android:layout_height="30dp"
                android:layout_marginLeft="2dp"
                android:textSize="12sp"
                android:checked="true"
                android:text="帧终结符"
                android:onClick="updateset5557"
                app:layout_constraintLeft_toRightOf="@+id/chkAOR"
                app:layout_constraintBottom_toBottomOf="@+id/chkAOR"/>

            <CheckBox
                android:id="@+id/chkPwdSetT5557"
                android:layout_width="wrap_content"
                android:layout_height="30dp"
                android:layout_marginLeft="2dp"
                android:textSize="12sp"
                android:checked="false"
                android:text="启用密码读写功能,并设密码为"
                android:onClick="updateset5557"
                app:layout_constraintLeft_toLeftOf="parent"
                app:layout_constraintTop_toBottomOf="@+id/chkAOR"/>

            <EditText
                android:id="@+id/editTextPwdSetT5557"
                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/chkPwdSetT5557"
                app:layout_constraintLeft_toRightOf="@+id/chkPwdSetT5557"
                app:layout_constraintTop_toTopOf="@+id/chkPwdSetT5557"

                />

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

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

            <EditText
                android:id="@+id/editTextConfigWordT5557"
                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:text="00088028"
                android:paddingLeft="3dp"
                android:textSize="12sp"
                app:layout_constraintLeft_toRightOf="@+id/TextViewlabel22"
                app:layout_constraintTop_toBottomOf="@+id/chkPwdSetT5557"
                />


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

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

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

            <Button
                android:id="@+id/btnT5557to4100"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:onClick="t5557to4100"
                android:text="t5557卡配置成ID卡"
                android:textSize="12sp"
                app:layout_constraintLeft_toLeftOf="parent"
                app:layout_constraintTop_toBottomOf="@+id/btnInitT5557"/>

            <TextView
                android:id="@+id/TextViewlabel23"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="厂商编码"
                android:textSize="12sp"
                app:layout_constraintTop_toTopOf="@+id/btnT5557to4100"
                app:layout_constraintBottom_toBottomOf="@+id/btnT5557to4100"
                app:layout_constraintLeft_toRightOf="@+id/btnT5557to4100" />

        </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.ouridr;
import com.reader.ourmifare;
public class T5557Activity extends AppCompatActivity {
    private TextView tv;
    private byte NEEDSERIAL = 0x01;   //需要只对指定系列号的卡操作
    private byte NEEDKEY = 0x02;      //需要用密码认证
    private byte LOCKBIT = 0x04;      //锁定配置块或数据块,仅对   t5557_init,t5557_write ,t5557_changekey函数有效
    private byte KEYENABLE = 0x08;    //启用本卡的密码功能
    private byte RESETCARD = 0x10;    //操作成功后重启卡片

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

        tv = findViewById(R.id.sample_text);
        tv.setText("操作结果");
    }
    @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 textclear5557(View view)
    {
        TextView tvls;
        tvls = findViewById(R.id.TextViewRetDataT5557);
        tvls.setText("");
    }

    public void default5557(View view)
    {
        EditText etls;
        CheckBox cbls;
        etls = findViewById(R.id.editTextConfigWordT5557);
        etls.setText("00088028");

        cbls = findViewById(R.id.chkAOR);//AOR请求应答模式
        cbls.setChecked(false);
        cbls = findViewById(R.id.chkFrameEnd);//帧终结符
        cbls.setChecked(true);
        cbls = findViewById(R.id.chkPwdSetT5557);//启用密码读写功能,并设密码为
        cbls.setChecked(false);
    }

    public void updateset5557(View view)
    {
        CheckBox cbls;
        CheckBox cbAOR;
        CheckBox cbPWD;

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

        etls = findViewById(R.id.editTextConfigWordT5557);
        String strls = etls.getText().toString().trim();
        if(strls.length() < 8){
            strls = "00088028";
            Configdata[0] = 0x00;
            Configdata[1] = 0x08;
            Configdata[2] = (byte)0x80;
            Configdata[3] = 0x28;
        }
        else {
            for (byte i = 0; i < 4; i++) {
                Configdata[i] = (byte)Integer.parseInt(strls.substring(i * 2, i * 2 + 2),16);//只有用Integer.parseInt才能杜绝大于128时的错误
            }
        }
        
        cbAOR = findViewById(R.id.chkAOR);//AOR请求应答模式
        cbPWD = findViewById(R.id.chkPwdSetT5557);//启用密码读写功能,并设密码为
        if(cbAOR.isChecked()) {
            if(!cbPWD.isChecked()) {//密码没启用,AOR无效
                cbAOR.setChecked(false);
                Configdata[2] &= 0xfd;
                tv.setText("密码没启用,AOR无效");
            }
            else {
                Configdata[2] |= 0x02;
            }
        }
        else {
            Configdata[2] &= 0xfd;
        }

        cbls = findViewById(R.id.chkFrameEnd);//帧终结符
        if(cbls.isChecked()) {
            Configdata[3] |= 0x08;
        }
        else {
            Configdata[3] &= 0xf7;
        }

        if(cbPWD.isChecked()) {
            if ((Configdata[3] & 0xe0) > (6 * 32)) {//启用密码功能后,最大块不能为7
                Configdata[3] &= 0x1f;
                Configdata[3] |=(6 * 32);
            }
            Configdata[3] |= 0x10;//启用密码功能
        }
        else{
            Configdata[3] &= 0xef;//取消密码功能
            Configdata[2] &= 0xfd;
            cbAOR.setChecked(false);
        }

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

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

        byte myctrlword;//控制字

        byte[] oldpicckey = new byte[4];//密码
        byte[] mypiccserial = new byte[6];//卡序列号
        byte[] newpicckey = new byte[4];//指定写哪一块

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

        String strls;

        CheckBox cbls;
        EditText etls;

        cbls = findViewById(R.id.chkPwdT5557);
        if(cbls.isChecked()) {//本次操作需要密码验证
            etls = findViewById(R.id.editTextPwdT5557);
            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.chkUidNeedT5557);
        if(cbls.isChecked()) {//仅操作指定卡号的卡
            etls = findViewById(R.id.editTextUidT5557);
            strls = etls.getText().toString().trim();
            if(strls.length() < 12)
            {
                tv.setText("卡号长度不足12位");
                return;
            }

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

        }

        etls = findViewById(R.id.editTextPwdNewT5557);
        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.t5557changekey(myctrlword,mypiccserial,oldpicckey,newpicckey);

        if(status == 0)
        {
            strls = "卡号[";
            strls += String.format("%02X%02X%02X%02X%02X%02X",mypiccserial[0],mypiccserial[1],mypiccserial[2],mypiccserial[3],mypiccserial[4],mypiccserial[5]);
            strls += "]";
            TextView tvls = findViewById(R.id.TextViewRetDataT5557);
            tvls.setText(strls);
            strls = "更改T5557卡密码成功";
            ouridr.beep(38);
        }
        else {
            strls=GetErrInf(status);
        }
        tv.setText(strls);

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

        byte myctrlword;//控制字

        byte[] oldpicckey = new byte[4];//密码
        byte[] mypiccserial = new byte[6];//卡序列号
        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.chkPwdT5557);
        if(cbls.isChecked()) {//本次操作需要密码验证
            etls = findViewById(R.id.editTextPwdT5557);
            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.chkUidNeedT5557);
        if(cbls.isChecked()) {//仅操作指定卡号的卡
            etls = findViewById(R.id.editTextUidT5557);
            strls = etls.getText().toString().trim();
            if(strls.length() < 12)
            {
                tv.setText("卡号长度不足12位");
                return;
            }

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

        }

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

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

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

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

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

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

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

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

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

        //第1页
        mypiccblockflag[1] = 0;

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

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

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

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

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

        if(status == 0)
        {
            strls = "卡无线转输分频比[" + Integer.toString(mypiccdata[0]) + "],卡号[";
            strls += String.format("%02X%02X%02X%02X%02X%02X",mypiccserial[0],mypiccserial[1],mypiccserial[2],mypiccserial[3],mypiccserial[4],mypiccserial[5]);
            strls += "],卡数据[";
            for (i = 0; i < mypiccdata[1]; i++) {
                strls += String.format("%02X",mypiccdata[i+2]);
            }
            strls += "]";

            TextView tvls = findViewById(R.id.TextViewRetDataT5557);
            tvls.setText(strls);
            strls = "读T5557卡成功";
            ouridr.beep(38);
        }
        else {
            strls=GetErrInf(status);
        }
        tv.setText(strls);
    }
    public void write5557(View view)
    {
        byte i;
        byte j;
        byte status;//存放返回值

        byte myctrlword;//控制字

        byte[] oldpicckey = new byte[4];//密码
        byte[] mypiccserial = new byte[6];//卡序列号
        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.chkPwdT5557);
        if(cbls.isChecked()) {//本次操作需要密码验证
            etls = findViewById(R.id.editTextPwdT5557);
            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.chkUidNeedT5557);
        if(cbls.isChecked()) {//仅操作指定卡号的卡
            etls = findViewById(R.id.editTextUidT5557);
            strls = etls.getText().toString().trim();
            if(strls.length() < 12)
            {
                tv.setText("卡号长度不足12位");
                return;
            }

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

        }

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

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

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

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

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

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

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

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

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

        //第1页
        mypiccblockflag[1] = 0;

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

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

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

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

        //写卡数据准备
        if(j == 0)
        {
            tv.setText("请先选择需要写入的块");
            return;
        }
        etls = findViewById(R.id.editTextDataT5557);
        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.t5557write(myctrlword,mypiccserial,oldpicckey,mypiccblockflag,mypiccdata);
        if(status == 0) {
            strls = "卡号[";
            strls += String.format("%02X%02X%02X%02X%02X%02X", mypiccserial[0], mypiccserial[1], mypiccserial[2], mypiccserial[3], mypiccserial[4], mypiccserial[5]);
            strls += "]";
            TextView tvls = findViewById(R.id.TextViewRetDataT5557);
            tvls.setText(strls);
            strls = "写T5557卡成功";
            ouridr.beep(38);
        }else {
            strls=GetErrInf(status);
        }
            tv.setText(strls);
    }


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

        byte myctrlword;//控制字

        byte[] oldpicckey = new byte[4];//密码
        byte[] mypiccserial = new byte[6];//卡序列号
        byte[] mypiccdata = new byte[4];//写入数据缓冲
        byte[] newpicckey = new byte[4];//指定写哪一块

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

        String strls;

        CheckBox cbls;
        EditText etls;

        cbls = findViewById(R.id.chkPwdT5557);
        if(cbls.isChecked()) {//本次操作需要密码验证
            etls = findViewById(R.id.editTextPwdT5557);
            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.chkPwdSetT5557);
        if(cbls.isChecked()) {//启用密码读写功能
            etls = findViewById(R.id.editTextPwdSetT5557);
            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时的错误
            }
            myctrlword += ouridr.KEYENABLE;

        }
        else {
            newpicckey[0] = 0x00;
            newpicckey[1] = 0x00;
            newpicckey[2] = 0x00;
            newpicckey[3] = 0x00;
        }

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

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

        }

        //配置值:
        etls = findViewById(R.id.editTextConfigWordT5557);
        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.t5557init(myctrlword,mypiccserial,oldpicckey,mypiccdata,newpicckey);
        if(status == 0) {
            strls = "卡号[";
            strls += String.format("%02X%02X%02X%02X%02X%02X",mypiccserial[0],mypiccserial[1],mypiccserial[2],mypiccserial[3],mypiccserial[4],mypiccserial[5]);
            strls += "]";
            TextView tvls = findViewById(R.id.TextViewRetDataT5557);
            tvls.setText(strls);
            strls = "配置T5557卡成功";
            ouridr.beep(38);
        }
        else {
            strls=GetErrInf(status);
        }
        tv.setText(strls);
    }

    public void t5557to4100(View view){
        byte[] myuidbuf=new byte[7];
        byte[] oldpicckey=new byte[4];
        byte[] newpicckey=new byte[4];
        byte[] mypiccserial=new byte[6];
        byte myctrlword=RESETCARD;

        myuidbuf[0]=47;
        myuidbuf[1]=1;
        myuidbuf[2]=2;
        myuidbuf[3]=3;
        myuidbuf[4]=4;

        byte status=ouridr.t5557to4100(myctrlword,mypiccserial,oldpicckey,newpicckey,myuidbuf);
        if (status==0){
            ouridr.beep(38);

            tv.setText("T5557卡配置成ID卡成功!");
        }else{
            tv.setText("错误代码:"+Integer.toString(status));
        }
    }

    public String GetErrInf(byte errcode) {
        String dispstr="";
        switch(errcode){
            case 1:
                dispstr="错误代码:1,写入配置的值不正确,配置区或密码区可能已被锁定,请重新写入!";
                break;
            case 2:
                dispstr="错误代码:2,本卡尚未开启密码功能,函数myctrlword中无需加入NEEDKEY!";
                break;
            case 3:
                dispstr="错误代码:3,需要指定密码,函数myctrlword要加入NEEDKEY!";
                break;
            case 5:
                dispstr="错误代码:5,密码错误!";
                break;
            case 8:
                dispstr="错误代码:8,卡不在感应区 或 密码不正确,请重新拿开卡后再放到感应区!";
                break;
            case 23:
                dispstr="错误代码:23,发卡器未连接!";
                break;
            default:
                dispstr="未知错误,错误代码:"+Integer.toString(errcode);
                break;
        }
       return dispstr;
    }

}

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

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

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

相关文章

【AI绘画+本地部署】基于krita的AI绘画(含windows一键整合包)

comfyuikrita所有相关资源整合包(无需下载后面链接)百度网盘&#xff1a;https://pan.baidu.com/s/1iwNRpdTaD26YbzSDm6WLDA?pwdbur8 –来自百度网盘超级会员V4的分享 krita绘画软件官网地址 https://krita.org/en/download/krita-desktop/ krita-ai-diffusion 插件&#xff…

对java的interface的理解

一个例子来让我们理解更加深刻 这是我们的整体文件布局 ①A是接口 ②B和C是用来实现接口的类 ③show是我们的运行函数&#xff0c;用来展示 A接口 接口中定义的方法可以不用去实现,用其他类去实现(必须实现) 关键字:interface public interface A { // public static …

Redis分布式锁存在的问题及解决方案(值得珍藏)

Redis分布式锁存在的问题 在购票软件的情境中&#xff0c;当仅剩一张或几张票时&#xff0c;众多用户同时尝试购买。在不考虑任何外部干扰的情况下&#xff0c;逻辑上&#xff0c;系统应首先检查是否还有余票。如果仍有余票&#xff0c;用户可以顺利购买并导致库存相应减少&am…

鸿蒙next开发-OpenHarmony的NDK开发

Native API&#xff08;NDK&#xff09;入门 Native API是OpenHarmony SDK上提供的一组native开发接口与工具集合&#xff08;也称为NDK&#xff09;&#xff0c;方便开发者使用C或者C语言实现应用的关键功能。Native API只覆盖了OHOS基础的一些底层能力&#xff0c;如libc&am…

史上最全EasyExcel

一、EasyExcel介绍 1、数据导入&#xff1a;减轻录入工作量 2、数据导出&#xff1a;统计信息归档 3、数据传输&#xff1a;异构系统之间数据传输 二、EasyExcel特点 Java领域解析、生成Excel比较有名的框架有Apache poi、jxl等。但他们都存在一个严重的问题就是非常的耗内…

制作一个Python聊天机器人

我们学习一下如何使用 ChatterBot 库在 Python 中创建聊天机器人&#xff0c;该库实现了各种机器学习算法来生成响应对话&#xff0c;还是挺不错的 什么是聊天机器人 聊天机器人也称为聊天机器人、机器人、人工代理等&#xff0c;基本上是由人工智能驱动的软件程序&#xff0…

代码随想录训练营第三十天|332.重新安排行程51. N皇后37. 解数独

332.重新安排行程 采用哈希表方式进行储存出发点和到达点&#xff0c;终止条件是result中的机场数量为机票1&#xff1b; 重点在于哈希表的运用和遍历方法 51. N皇后 wtf? 回溯算法非常形象的N叉树解法&#xff1a; 输入n&#xff0c;row col,chessboard 终止条件&#x…

2024年pmp的考试时间是什么时候?

2024最新考试时间已经出来了&#xff1a;分别是 3月、6月、8月、11月&#xff0c;四次&#xff0c;具体考试日期还需要关注官网的进一步通知。 一、PMP报考条件 年龄满足 22 周岁有官方授权的培训机构给的 35个PDU&#xff08;学时&#xff09; 就能报名。 是不是相当于没有…

[Python] 如何通过ctypes库来调用C++ 动态库 DLL?

ctypes库介绍 ctypes是Python的一个外部库,它提供了一种灵活的方式来调用C语言的动态链接库(DLL)或共享库(SO)。通过ctypes,我们可以在Python中直接调用C语言编写的函数和变量,从而实现跨语言的互操作。 ctypes 它提供了与 C 兼容的数据类型,并允许调用 DLL 或共享库中的…

本地MinIO存储服务通过Java程序结合Cpolar内网穿透进行远程连接

文章目录 前言1. 创建Buckets和Access Keys2. Linux 安装Cpolar3. 创建连接MinIO服务公网地址4. 远程调用MinIO服务小结5. 固定连接TCP公网地址6. 固定地址连接测试 前言 MinIO是一款高性能、分布式的对象存储系统&#xff0c;它可以100%的运行在标准硬件上&#xff0c;即X86等…

【Linux系列】在Pop!OS的启动器中添加自定义程序图标

文章目录 前言一、创建快捷方式二、快捷方式参数三、添加右键菜单和注册MIME 前言 无论是在Windows上&#xff0c;还是Linux&#xff0c;或者安卓这些我们常用的操作系统上&#xff0c;一些应用程序的快捷方式放在桌面或者启动器&#xff0c;只需要简单的点击就可以启动&#…

【算法】串联所有单词的子串【滑动窗口】

题目 给定一个字符串 s 和一个字符串数组 words。 words 中所有字符串 长度相同。s 中的 串联子串 是指一个包含 words 中所有字符串以任意顺序排列连接起来的子串。例如&#xff0c;如果 words ["ab","cd","ef"]&#xff0c; 那么 "abcd…

Unity 编辑器篇|(十一)Gizmos (全面总结 | 建议收藏)

目录 1. 前言2 参数总览3 Gizmos绘制3.1 立方体&#xff1a;DrawCube3.2 视锥&#xff1a;DrawFrustum3.3 贴图&#xff1a;DrawGUITexture3.4 图标&#xff1a;DrawIcon3.5 线段&#xff1a;DrawLine3.6 网格&#xff1a;DrawMesh3.7 射线&#xff1a;DrawRay3.8 球体&#xf…

PBR材质背光面太暗优化

图形学中漫反射光照遵循兰伯特光照模型&#xff0c;它的公式如下 其中&#xff1a; &#xff1a;漫反射光颜色 &#xff1a;入射光颜色 &#xff1a;材质的漫反射系数 &#xff1a;法线方向 &#xff1a;光源方向 由于背光面的法线方向和光源方向的点积为负数&#xff0c;因此…

为什么 Golang Fasthttp 选择使用 slice 而非 map 存储请求数据

文章目录 Slice vs Map&#xff1a;基本概念内存分配和性能Fasthttp 中的 SliceMap性能优化的深层原因HTTP Headers 的特性CPU 预加载特性 结论 Fasthttp 是一个高性能的 Golang HTTP 框架&#xff0c;它在设计上做了许多优化以提高性能。其中一个显著的设计选择是使用 slice 而…

golang 中使用 statik 将静态资源编译进二进制文件中

现在的很多程序都会提供一个 Dashboard 类似的页面用于查看程序状态并进行一些管理的功能&#xff0c;通常都不会很复杂&#xff0c;但是其中用到的图片和网页的一些静态资源&#xff0c;如果需要用户额外存放在一个目录&#xff0c;也不是很方便&#xff0c;如果能打包进程序发…

shell编程-3

文章目录 shell学习第三天while 循环第一天的小游戏练习: 编写抽同学回答问题的脚本要想让这个脚本永久有效如何知道两个文件里的内存一样&#xff1f;如何判断某个人已经抽过了 文本处理相关命令seqxargsuniqsorttrcutawkpastesplitcoljoin小结一下作业 小知识点写脚本的流程怎…

基于SkyEye仿真飞腾处理器:运行U-Boot并加载Phytium-FreeRTOS

仿真平台在帮助提升研发效率、加快产品面市时间上的作用已得到诸多验证&#xff0c;通过对处理器进行仿真来支持嵌入式系统及软件的虚拟化开发、测试和验证成为目前应用较为广泛的方法。天目全数字实时仿真软件SkyEye是一款基于可视化建模的硬件行为级仿真平台&#xff0c;在众…

找免费PPT素材、模板,就上这6个网站。

这6个PPT模板网站&#xff0c;免费下载&#xff0c;可商用&#xff0c;赶紧来下载。 1、菜鸟图库 https://www.sucai999.com/search/ppt/0_0_0_1.html?vNTYxMjky 菜鸟图库是一个设计、办公、媒体等素材非常齐全的网站&#xff0c;站内有几百万的庞大素材库&#xff0c;其中PP…

Python 异源mesh裁剪融合实现与优化

Python 异源mesh裁剪融合实现与优化 一、项目需求二、解决方案1. 代码2. 结果3. 耗时 三、优化探索0. 分析1. 在体素边界处进行裁剪2. 用mesh分块进行裁剪3. 用缓冲区的思路裁剪 一、项目需求 对mesh进行裁剪&#xff0c;但发现若非mesh是致密的&#xff0c;那么裁剪边会出现锯…