Communication by I2C in JCOP4.x

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Communication by I2C in JCOP4.x

1,732 Views
nxp36440
NXP Employee
NXP Employee

To communcation JCOP4.x by I2C, please find example code for reference

Please also check items as folllwing in advance.

1. Confirm base OS support I2C

2. Check parameter configuration

     I2C_SPI_PARAMS

     ATR_I2C_IF_BYTES

 

 

Labels (1)
4 Replies

1,137 Views
msjcard
Contributor III

The code was helpful, but has an error in it in I2CTester.java:

This section should be - 

case I2C_TRANSFER:
    //The communications configuration needs to be set up for each call of the API.
    //All TLV TAGS to do this must be present in the input buffer
    len = I2cMaster.i2cMaster(buf, ISO7816.OFFSET_CDATA, len, buf, (short)0, (short)225);
    apdu.setOutgoingAndSend((short) (0), len);

(e.g. the output length should match the return length from the I2CMaster.i2cMaster call, and the buffer length shouldn't be set by the length of the incoming command, but should be closer to  the  length of the APDU buffer)

0 Kudos
Reply

1,098 Views
msjcard
Contributor III

Here's the fixed I2C_Tester.java file.  For some unknown reason, this forum doesn't support uploads of .java files - so I added a .c at the end.  Save the file, remove the .c and you should be able to compile this.

This fixes a few bugs in the sample code provided by NXP.

0 Kudos
Reply

999 Views
msjcard
Contributor III

For some reason, the code I sent didn't upload.  Let me try again.  This is corrected I2C_Tester.java - but .java files aren't supported as uploads for some reason so this is here as .txt

0 Kudos
Reply

1,683 Views
nxp36440
NXP Employee
NXP Employee

Please use default value for parameter I2C_SPI_PARAMS and ATR_I2C_IF_BYTES

0 Kudos
Reply
%3CLINGO-SUB%20id%3D%22lingo-sub-2166220%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ECommunication%20by%20I2C%20in%20JCOP4.x%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2166220%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3ETo%20communcation%20JCOP4.x%20by%20I2C%2C%20please%20find%20example%20code%20for%20reference%3C%2FP%3E%0A%3CP%3EPlease%20also%20check%20items%20as%20folllwing%20in%20advance.%3C%2FP%3E%0A%3CP%3E1.%20Confirm%20base%20OS%20support%20I2C%3C%2FP%3E%0A%3CP%3E2.%20Check%20parameter%20configuration%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%3CSPAN%20class%3D%22uioutputtext%22%3E%3CSPAN%3EI2C_SPI_PARAMS%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22uioutputtext%22%3E%3CSPAN%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3BATR_I2C_IF_BYTES%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CBR%20%2F%3E%0A%3CBR%20%2F%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2166220%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CLINGO-LABEL%3ESmart%20Cards%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2170072%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20Communication%20by%20I2C%20in%20JCOP4.x%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2170072%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EPlease%20use%20default%20value%20for%20parameter%26nbsp%3B%3CSPAN%20class%3D%22uioutputtext%22%3E%3CSPAN%3EI2C_SPI_PARAMS%20and%26nbsp%3B%3C%2FSPAN%3E%3C%2FSPAN%3E%3CSPAN%20class%3D%22uioutputtext%22%3E%3CSPAN%3EATR_I2C_IF_BYTES%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2336816%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20Communication%20by%20I2C%20in%20JCOP4.x%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2336816%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EThe%20code%20was%20helpful%2C%20but%20has%20an%20error%20in%20it%20in%20I2CTester.java%3A%3C%2FP%3E%3CP%3EThis%20section%20should%20be%20-%26nbsp%3B%3C%2FP%3E%3CP%3Ecase%20I2C_TRANSFER%3A%3CBR%20%2F%3E%26nbsp%3B%20%26nbsp%3B%20%2F%2FThe%20communications%20configuration%20needs%20to%20be%20set%20up%20for%20each%20call%20of%20the%20API.%3CBR%20%2F%3E%26nbsp%3B%20%26nbsp%3B%20%2F%2FAll%20TLV%20TAGS%20to%20do%20this%20must%20be%20present%20in%20the%20input%20buffer%3CBR%20%2F%3E%26nbsp%3B%20%26nbsp%3B%20len%20%3D%20I2cMaster.i2cMaster(buf%2C%20ISO7816.OFFSET_CDATA%2C%20len%2C%20buf%2C%20(short)0%2C%20(short)225)%3B%3CBR%20%2F%3E%26nbsp%3B%20%26nbsp%3B%20apdu.setOutgoingAndSend((short)%20(0)%2C%20len)%3B%3C%2FP%3E%3CP%3E(e.g.%20the%20output%20length%20should%20match%20the%20return%20length%20from%20the%20I2CMaster.i2cMaster%20call%2C%20and%20the%20buffer%20length%20shouldn't%20be%20set%20by%20the%20length%20of%20the%20incoming%20command%2C%20but%20should%20be%20closer%20to%26nbsp%3B%20the%26nbsp%3B%20length%20of%20the%20APDU%20buffer)%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2337192%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20Communication%20by%20I2C%20in%20JCOP4.x%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2337192%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHere's%20the%20fixed%20I2C_Tester.java%20file.%26nbsp%3B%20For%20some%20unknown%20reason%2C%20this%20forum%20doesn't%20support%20uploads%20of%20.java%20files%20-%20so%20I%20added%20a%20.c%20at%20the%20end.%26nbsp%3B%20Save%20the%20file%2C%20remove%20the%20.c%20and%20you%20should%20be%20able%20to%20compile%20this.%3C%2FP%3E%3CP%3EThis%20fixes%20a%20few%20bugs%20in%20the%20sample%20code%20provided%20by%20NXP.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2345774%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20Communication%20by%20I2C%20in%20JCOP4.x%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2345774%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EFor%20some%20reason%2C%20the%20code%20I%20sent%20didn't%20upload.%26nbsp%3B%20Let%20me%20try%20again.%26nbsp%3B%20This%20is%20corrected%20I2C_Tester.java%20-%20but%20.java%20files%20aren't%20supported%20as%20uploads%20for%20some%20reason%20so%20this%20is%20here%20as%20.txt%3C%2FP%3E%3C%2FLINGO-BODY%3E