1 回答
TA贡献1934条经验 获得超2个赞
您需要考虑如何更新联合中的字段。显然,你不能让用户在没有验证的情况下这样做。他们可能会进行不一致的更新。考虑做这样的事情:
package mifare
const (
MDFTStandarDataFile = 0x00
MDFTBackupDataFile = 0x01
MDFTValueFileWithBackup = 0x02
MDFTLinearRecordFileWithBackup = 0x03
MDFTCyclicRecordFileWithBackup = 0x04
)
type StandardFile struct {
FileSize uint32
}
type ValueFile struct {
LowerLimit int32
UpperLimit int32
LimitedCreditValue int32
LimitedCreditEnabled uint8
}
type LinearRecordFile struct {
Record_size uint32
MaxNumberOfRecords uint32
CurrentNumberOfRecords uint32
}
type DESFireFileSettings struct {
FileType uint8
CommunicationSettings uint8
AccessRights uint16
settings struct {
StandardFile
ValueFile
LinearRecordFile
}
}
func (fs *DESFireFileSettings) StandardFile() (StandardFile, error) {
// if not valid for FileType, return error
return fs.settings.StandardFile, nil
}
func (fs *DESFireFileSettings) SetStandardFile(standardFile StandardFile) error {
// if not valid for FileType, return error
fs.settings.StandardFile = standardFile
return nil
}
func (fs *DESFireFileSettings) ValueFile() (ValueFile, error) {
// if not valid for FileType, return error
return fs.settings.ValueFile, nil
}
func (fs *DESFireFileSettings) SetValueFile(valueFile ValueFile) error {
// if not valid for FileType, return error
fs.settings.ValueFile = valueFile
return nil
}
func (fs *DESFireFileSettings) LinearRecordFile() (LinearRecordFile, error) {
// if not valid for FileType, return error
return fs.settings.LinearRecordFile, nil
}
func (fs *DESFireFileSettings) SetLinearRecordFile(linearRecordFile LinearRecordFile) error {
// if not valid for FileType, return error
fs.settings.LinearRecordFile = linearRecordFile
return nil
}
- 1 回答
- 0 关注
- 196 浏览
添加回答
举报