How can I write a read a data on a SmartCArd

Hi everyone...
I would like to know. how I can write and read a data on a SmartCard maybe through a file(IO)
could you helpme please??
Thanks a lot...
Marcos

Try this mate
package com.reader;
import java.util.List;
import javax.smartcardio.Card;
import javax.smartcardio.CardChannel;
import javax.smartcardio.CardException;
import javax.smartcardio.CardTerminal;
import javax.smartcardio.CardTerminals;
import javax.smartcardio.CommandAPDU;
import javax.smartcardio.ResponseAPDU;
import javax.smartcardio.TerminalFactory;
import com.sun.javacard.apduio.Apdu;
* @author ic008391
public class Connector extends Thread
     * @param args
     * @param args
     public static void main(String[] args)
          List<CardTerminal> lct = null;
          Card crd = null;
          TerminalFactory tf = TerminalFactory.getDefault();
          CardTerminals cts = tf.terminals();
          CardChannel cch = null;
          try
               //create APDU Command
               Apdu apdu = new Apdu();
               apdu.command[Apdu.CLA] = (byte) 0X00;
               apdu.command[Apdu.INS] = (byte) 0XA4;
               apdu.command[Apdu.P1] = (byte) 0X04;
               apdu.command[Apdu.P2] = (byte) 0X00;
               //apdu.command[Apdu.P3] = (byte) 0X0a;
               byte[] data = {(byte)0xa0, (byte)0x0, (byte)0x0, (byte)0x0, (byte)0x62, (byte)0x3, (byte)0x1, (byte)0xc, (byte)0x6, (byte)0x1, (byte)0x7F};
//wallet 0xa0:0x0:0x0:0x0:0x62:0x3:0x1:0xC:0x6
// select 0x00 0xA4 0x04 0x00 0x0a 0xa0 0x0 0x0 0x0 0x62 0x3 0x1 0xc 0x6 0x1 0x7F
               lct = cts.list();
               System.out.println(lct);
               CardTerminal ct = lct.get(0);
               crd = ct.connect("T=0"); //Or "T=1"
               javax.smartcardio.ATR atr = crd.getATR();
               byte i[] =atr.getBytes();
               for (int n = 0; n < i.length; n++) {
          int x = (int) (0x000000FF & i[n]); // byte to int conversion
          String s = Integer.toHexString(x).toUpperCase();
          if (s.length() == 1) s = "0" + s;
          System.out.print(s + " ");
               System.out.println("");
               System.out.println("ATR"+(atr.getHistoricalBytes()).toString());
               System.out.println("ATR"+atr.toString());
               cch = crd.getBasicChannel();
               sleep(1000);
               ResponseAPDU r;
               //r = cch.transmit(new CommandAPDU(apdu.getCommand()));
               r = cch.transmit(new CommandAPDU(0,164,4,0,data));
               System.out.println(apdu);
               System.out.println(r);
               //Get Balance
               //0xB0 0x50 0x00 0x00 0x00 0x02;
               r = cch.transmit(new CommandAPDU(176,80,0,0));
               System.out.println(r);
               //cch.close();
          catch (CardException e)
               // TODO Auto-generated catch block
               e.printStackTrace();
          catch (InterruptedException e)
               // TODO Auto-generated catch block
               e.printStackTrace();
          finally
               try
                    crd.disconnect(true);
               catch (CardException e)
                    // TODO Auto-generated catch block
                    e.printStackTrace();
}

Similar Messages

  • How can i write and read the same data

    hi,
             i have attached my program to this mail. i have some problems in this program.
    problems:
    1. I want to select the threshold for the rms,varience and s.d.
    But what i used is not doing that. i want to fix the upper threshold value and lower threshold value.
     when ever the input crosses upper threshold value i want the output and it will remains uptill the value above the lower threshold value.
    Once it come down the lower threshold value the output should be stopped.
    2. I want to write this in to a  file and i want to read this file. is this possible or not. 
                please try to help me i am very new with lab view6i
           REGARDS
    CHAMARTHY KOMAL DILEEP.
       [email protected]
    Attachments:
    dileep.vi ‏93 KB

    The easiest way to perform a certain action (such as file I/O) based on a certain condition (such as whether a value has passed a certain threshold) is to use a comparison VI in combination with a case structure. Then you can specify that if your rms, standard deviation and variance are above a threshold then perform a certain action.
    Also consider using shift registers to keep track of data from the last loop. If I understand you correctly, you want to start logging data when an upper threshold has been passed. Then you want to continue logging data until a lower threshold is passed. I have attached a non-functional but explanatory VI that will help explain how to implement logic to that effect. It also demonstrates that you can indeed write and read from the same file in a loop. The best way to do this is to open the file before the loop, do all the necessary writing and reading in the loop, and then close the file after the loop.
    Hope this helps!
    Jarrod S.
    National Instruments
    Attachments:
    dileep_example.vi ‏61 KB

  • How can I write the name of data into Excel?

    Now, I write T1 T2 T3 and so on into an excel file and each is in one column. How can I insert the data name such as " T1 T2 T3" on the top row by programming? 
    I am using "write to spreadsheet file. vi" now and wire the data with "build array".

    How can you creat the "red box" (linked to append report text.vi)  with name as Pressure, temperature, operator ?  
    Actually, I use much simpler way. Could you please have a look at it?
    I attach an vi file to express my meaning.
    附件:
    save try.vi ‏40 KB

  • How can I write and read the LPT within JAVA?

    Hello!
    I'm new to JAVA.
    I made a simple JAVA application with few buttons and labels with NetBeans.
    I add ActionListener to button but don't know to write the handling code that should to write a byt to the DATA register in the LPT port of the PC box.
    From where can I get the code for this, maybe within JDK documentation?
    Any advices will be appreciated!
    Regards, csPaul

    I have ever programmed an LPT data sender using VB.net and inpout32.dll(will be very easy to search using google). for Java, try this:
    http://www.geocities.com/Juanga69/parport/
    I've just download the sample also, wanna try to...
    And some people say that JNI allow us to embedd C++ code within our Java program.. I don't know about this yet...

  • How can i write max and min data online during acquisition

    Hello,
    I am not keen with programming and your help will be greatly appreciated.
    I make temperature acquisition from an IR camera and I record online 38 different spots at a frequency of 10 samples/min.
    I also record two temperatures from thermocouples at the same sampling rate.
    I would like to make the acquisition during 5 sec every 20 sec and extract the max and min temperature from the thermocouples and write these values in a text file like show below :
    Temp_max 5 sec 22.1
    Temp_min 5 sec 2.1
    Temp_max 10 sec 42.1
    Temp_min 10 sec 4.1
    Temp_max 15 sec 82.1
    Temp_min 15 sec 6.1
    I also would like to make the same with two or three different spots of the IR camera. I think that if I have a good solution for the thermocouple, I can make it for the camera.
    I use LabView 8.2 with NIDaqmx acquisition.
    Thank you in advance

    Hello Evrem,
    Thank you for your advice. In fact, I have already attended to the training course you mentioned. I should think about going to the module Basic II. I do not have problem to connect/pilot various type of instruments but I am not very efficient with loop and arrays !
    I am fine with the data acquisition and the timing and I can sort data during 5 sec with "Array max & min". Then, I can display all data. What I have problem to do is to extract the max & min from the array, keep these 2 values for being writtten in a file at the end of my loop and start again during the next 5-sec cycle. At present, I only have the last max & min results from the last acquisition !
    Any example of how recording max & min online during 5-sec cycle acquisition will be welcome.
    Best regards,
    Labdummy

  • I am connecting an external USB HDD and I can see it on my Apple Macbook Air. BUT this drive is READ only. How can I write to it?

    I am connecting an external USB HDD and I can see it on my Apple Macbook Air. BUT this drive is READ only. How can I write to it?

    Drive Partition and Format
    1.Open Disk Utility in your Utilities folder.
    2. After DU loads select your hard drive (this is the entry with the mfgr.'s ID and size) from the left side list. Click on the Partition tab in the DU main window.
    3. Under the Volume Scheme heading set the number of partitions from the drop down menu to one. Click on the Options button, set the partition scheme to GUID then click on the OK button. Set the format type to Mac OS Extended (Journaled.) Click on the Partition button and wait until the process has completed.
    4. Select the volume you just created (this is the sub-entry under the drive entry) from the left side list. Click on the Erase tab in the DU main window.
    5. Set the format type to Mac OS Extended (Journaled.) Click on the Security button, check the button for Zero Data and click on OK to return to the Erase window.
    6. Click on the Erase button. The format process can take up to several hours depending upon the drive size.
    Steps 4-6 are optional but should be used on a drive that has never been formatted before, if the format type is not Mac OS Extended, if the partition scheme has been changed, or if a different operating system (not OS X) has been installed on the drive.

  • I have a FAT 32 External Hard Drive marked as Read Only that is unchangeable by an administrator or root user, how can I make it read/Write

    Hello, All,
    I have a FAT 32 External Hard Drive marked as Read Only that is unchangeable by an administrator or root user, how can I make it read/Write without reformatting it ? 

    Hi Kappy,
    Just wondering if you had any advice for my situation . . .
    My time machine backup was backing up to a drive that was "Mac OS X Enteded Journaled, Case Sensitive."  I had no idea what this meant, or that it would even cause issues.
    I took my computer to the Apple store yesterday, and they wiped it clean.  When they tried to restore it from the Time Machine backup drive, it would not work.  Their guess is that Time Machine cannot restore from a drive that is "case sensitive."
    Any thoughts on how I can convert my time machine backup data from a "case sensitive" state, to a "non-case sensitive" state?  I've tried to just drag and drop the files from the case sensitive formatted drive to a new drive that I have that is formatted non case sensitive, but I get the following error message:
    "The volume has the wrong case sensitivity for a backup"
    I just really want my data back - I thought TimeMachine was the way to go (and was supposed to work) but unfortunately it is not.
    Any help you can provide would be greatly appreciated.
    Thanks,

  • How can we make the ms-word data as read-only using java code?

    How can we make the ms-word data as read-only using java code?

    MVSK wrote:
    By using java code i opened a file in ms-word. But the data i want to display as read-only. that means should not change it.I don't think you can do that. Display pdf documents instead.

  • How can i write the data to PIC16F819 using labview?

    how can i write the data to PIC16F819 using labview?
    Need help!
    im using labview in gathering the datas that i need to right to the PIC, then after getting all the datas i am using another program which is ICD2 in order to write it to the PIC. Is it possible to do this task through LV? coz we are spending a lot of time transferring the data from LV to ICD2 manually and its prone to mistake as well.
    any suggestion?
    thanks,
    Pedz

    LabVIEW does not currently have a built-in method to communicate with
    i2c, but there are other vendors that sell devices to communicate in
    this manner with LabVIEW development kits.  One that I know of is
    from MCC... here is a link:  http://www.mcc-us.com
    They sell a device called iPort, and then you can buy LabVIEW VIs to go with it.  I hope this is helpful to you!
    john m

  • How can I modify the High Speed Data Reader VI to show correct time informatio​n in x-axis?

    I am just a beginner learning the LabVIEW programming currently.
    I have a PXI 6115 DAQ card and have to make a hardware timed acquisition VI for maximum performance. Thus I use the High Speed Data Logger VI for data acquisition.
    However, when I read my data by using the High Speed Data Reader VI, it doesn't show its correct time information in the graph.
    How can I modify the High Speed Data Reader VI to show correct time information in x-axis?
    I hope you can explain easily because I am a beginner.

    Hey Chunrok,
    I've modified the High Speed Data Reader VI slightly so that it now uses the scan rate of the data (as determined from the file) to set the scaling for the data points. If you wanted the start time to be a specific time you could use the start time obtained from your file to set the xscale offset as well.
    I hope this helps!
    Sarah Miracle
    National Instruments
    Attachments:
    Example.vi ‏281 KB

  • How can I modify the High Speed Data Reader VI to show the time information in x-axis?

    I am just a beginner learning the LabVIEW programming currently.
    I have a PXI 6115 DAQ card and have to make a hardware timed acquisition VI for maximum performance. Thus I use the High Speed Data Logger VI for data acquisition.
    However, when I read my data by using the High Speed Data Reader VI, it doesn't show its time information in the graph.
    How can I modify the High Speed Data Reader VI to show the time information in x-axis?
    I hope you can explain easily because I am a beginner.

    Format the x axis to either absoulte or relative time.
    You can do this by right clickingo n the graph and selecting x axis then formatting from the menu.
    Thanks,
    Naresh

  • How can I modify the High Speed Data Reader VI to show correct time information in x-axis?

    I am just a beginner learning the LabVIEW programming currently.
    I have a PXI 6115 DAQ card and have to make a hardware timed acquisition VI for maximum performance. Thus I use the High Speed Data Logger VI for data acquisition.
    However, when I read my data by using the High Speed Data Reader VI, it doesn't show its correct time information in the graph.
    How can I modify the High Speed Data Reader VI to show correct time information in x-axis?
    I hope you can explain easily because I am a beginner.

    First, I couldn't seem to find that example either on computer or on the NI sites.
    The problem that we're running into is stated in the article that I pointed to - when real time VIs are running, then the OS will stop updating the OS clock. TO us it looks like the clock is losing time. There is a hardware clock on the PXI and it is read only during boot up to set the OS clock. Our discussions with NI have not led to a solution for this problem without checking the time on start and then checking the tick count (which does not lose time) and calculating what the current time is. No access to the hardware clock is supplied.
    We're still working on a simpler way to get accurate time.
    Rob

  • How can i write a XML file with oracle data ?

    How can i write a XML file using PL/SQL.
    Can i do as follows.
    1.Open a file using UTL_FILE.FOPEN(LC_DIR_LOC,'abc.xml','W')     ;
    2.write all the required tag and value using UTL.put_line
    that is enough. Is not, please guide me to write.
    gk

    Having Oracle 9i.
    One more doubt. In the speck, some constand values are there, When i write the same into file, How can i write ?.
    1. l_str := ' "E27" '
    or
    2. l_str := ' E27 '
    UTL_FILE.PUT_LINE(L_FILE_POI,l_str,TRUE);          
    1 case : in XML file : "E27"
    In 2 case : E27
    When we write a XML file through editors , we have to define the constant within quote . is it?      
    Which one can i use ? Or any other way is there ..
    Thanks and Regards
    gopi

  • How can I Write a sine wave in an Access-fil​e?

    I measure a sine wave in LabView 6i. How can I write the datas automatically to an Acces-file, at the same time?
    In my program, I managed it with Execute SQL.vi, I change a number in a SQL statement(String) -> after this I push start and then it writes the statement in the Access-file.
    The problem is, it writes only one data per measurement in the file. How can I write all datas in the Access-file and measure the wave at the same time?
    Thanks for help!
    Attachments:
    getwave.vi ‏49 KB

    On the waveform palette, you will find a "to components" vi that you can break out the array of the waveform. You can then, using a for loop write all of the values from the waveform.
    Better yet, there are examples in the database toolkit manual on pages 3-13 to 3-15 that deal with reading arrays (and even has a waveform example).
    Good luck!

  • How can I write into a table cell (row, column are given) in a databae?

    How can I write into a table cell (row, column are given) in a database using LabVIEW Database Toolkit? I am using Ms Access. Suppose I have three columns in a table, I write 1st row of 1st column, then 1st row of 3rd column. The problem I am having is after writing the 1st row 1st column, the reference goes to second row and if I write into 3rd column, it goes to 2nd row 3rd column. Any suggestion? 
    Solved!
    Go to Solution.

    When you do a SQL INSERT command, you create a new row. If you want to change an existing row, you have to use the UPDATE command (i.e. UPDATE tablename SET column = value WHERE some_column=some_value). The some_column could be the unique ID of each row, a date/time, etc.
    I have no idea what function to use in the toolkit to execute a SQL command since I don't use the toolkit. I also don't understand why you just don't do a single INSERT. It would be much faster.

Maybe you are looking for

  • How I got Xorg working under Optimus

    I have just gone through the process of installing Arch Linux on my laptop(Dell Latitude E6420, NVS 4200M + Intel IGFX), without any major issues. I used the Beginner's Guide, the Bumblebee wiki page, and the 'installing X' wiki page to assist my ins

  • White Screen when "video" chatting with PC

    My friend is running AIM 5.9 on Windows XP and when I try to video chat with her, all she sees is a white screen, but still can hear me. I have rebooted my computer, and so has she. We used to not be able to connect at all, but she rebooted and now s

  • MacBook killing wireless network

    I have the MacBook 1.1 . Router is Linksys WRT54G. Up until approximately 2 weeks ago the network has worked without issue. For some reason the MacBook is killing the wireless network. I thought it was my ISP at first but then narrowed it down to the

  • Onhand report showing available and reserved quantities

    Hi, we are inventory organization using Oracle Apps R12.1 Is there any reports showing onhand with Availability Details ? I mean showing free & reserved stock quantities . If no , can any one provide sql statement or any suggestion can help ? Thanks

  • Robohelp 6 asian pack

    Hello, A question. Are you currently making RoboHelp 6 for Japanese and Chinese languages? Or, do you consider making it in the near future? Thank you. victor