我正在使用Android手机在NT3H2111 nfc芯片的EEPROM中读取和写入一些数据。
更改扇区的方法似乎正在起作用,但无论如何,当我尝试读取内容时,扇区没有更改,它仍然位于扇区0上。
declare @flg int=3--test with 1,2,3,4 ...
create table #temp(id int identity(1,1),col varchar(10))
insert into #temp values ('A'),('B'),('C'),('D'),('E'),('F'),('G'),('H')
create table #temp1(id int ,col varchar(10),flag int,rownum int)
declare @PvtCol varchar(500)=''
declare @Headcol varchar(500)
declare @Sql nvarchar(500)
WITH CTE
AS (SELECT id,
col,
CASE
WHEN(id % @flg) = 0
THEN @flg
ELSE(id % @flg)
END flag
FROM #temp),
CTE1
AS (SELECT *,
ROW_NUMBER() OVER(PARTITION BY flag
ORDER BY id) rownum
FROM cte)
INSERT INTO #temp1
(id,
col,
flag,
rownum
)
SELECT id,
col,
flag,
rownum
FROM cte1;
SELECT @PvtCol = COALESCE(@PvtCol + ', ' + QUOTENAME(rownum), QUOTENAME(rownum)),
@Headcol = COALESCE(@Headcol + ', ' + QUOTENAME(rownum) + ' as ' + 'col', QUOTENAME(rownum) + ' as ' + 'col') + CAST(rownum AS VARCHAR)
FROM #temp1
WHERE flag = 1;
SET @PvtCol = STUFF(@PvtCol, 1, 1, '');
SELECT @PvtCol,
@Headcol;
SET @Sql = 'select flag,' + @Headcol + ' from
(
select flag, col,rownum from #temp1
)src
pivot(max(col) for rownum in(' + @PvtCol + ')) as pvt';
PRINT @Sql;
EXECUTE sp_executesql
@Sql;
DROP TABLE #temp, #temp1;
...
@Override
protected void onNewIntent(Intent intent) {
try {
Tag tag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG);
ntagHandler = new NtagHandler(tag);
ntagHandler.connect();
if(mode == AppMode.READ) {
Ve95_DataModelHandler.readSectionNames(ve95DataModel, ntagHandler);
populateView();
} else if(mode == AppMode.WRITE) {
populateDataModel();
Ve95_DataModelHandler.writeSectionNames(ve95DataModel, ntagHandler);
}
ntagHandler.close();
ImageView img = findViewById(R.id.imageViewNFCConnect);
if(img != null) {
img.setVisibility(View.INVISIBLE);
mode = AppMode.READ;
}
} catch(IOException e) {
Toast.makeText(this, "Caught exception: " + e.toString(), Toast.LENGTH_LONG).show();
}
}
...
public boolean sectorSelect(int sector) throws IOException {
byte[] cmd_sel1 = { (byte)0xC2, (byte)0xFF };
byte[] cmd_sel2 = { (byte)sector, (byte)0x00, (byte)0x00, (byte)0x00 };
byte[] result1 = nfca.transceive(cmd_sel1);
if (result1 == null) {
throw new TagLostException();
} else if ((result1.length == 1) && ((result1[0] & 0x00A) == 0x000)) {
return false;
} else {
try {
byte[] result2 = nfca.transceive(cmd_sel2);
if (result2 == null) {
throw new TagLostException();
} else if ((result2.length == 1) && ((result2[0] & 0x00A) == 0x000)) {
// NACK response according to DigitalProtocol
return false;
} else {
return true;
}
} catch (Exception e) {
// passive ACK
Log.d(TAG, "sectorSelect caught exception, but succeeded anyway");
return true;
}
}
}
我得到了这个结果,但是从数据中我可以看到该扇区仍然为零,并且尚未更改为扇区1。
D / Ve95_DataModelHandler:读取节名称
D /:sectorSelect捕获了异常,但还是成功了
D / Ve95_DataModelHandler:扇区选择返回true
D / Ve95_DataModelHandler:04,B2,87,CA,D4,64,80,00,44,00,00,00,00 ....
有人知道如何改变行业吗?
致谢
亨里克
答案 0 :(得分:0)
自己解决了。安装了1K芯片而不是2K芯片。难怪它没有用:)