€•&4Œsphinx.addnodes”Œdocument”“”)”}”(Œ rawsource”Œ”Œchildren”]”(Œ translations”Œ LanguagesNode”“”)”}”(hhh]”(hŒ pending_xref”“”)”}”(hhh]”Œdocutils.nodes”ŒText”“”ŒChinese (Simplified)”…””}”Œparent”hsbaŒ attributes”}”(Œids”]”Œclasses”]”Œnames”]”Œdupnames”]”Œbackrefs”]”Œ refdomain”Œstd”Œreftype”Œdoc”Œ reftarget”Œ4/translations/zh_CN/driver-api/serial/serial-iso7816”Œmodname”NŒ classname”NŒ refexplicit”ˆuŒtagname”hhh ubh)”}”(hhh]”hŒChinese (Traditional)”…””}”hh2sbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ4/translations/zh_TW/driver-api/serial/serial-iso7816”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)”}”(hhh]”hŒItalian”…””}”hhFsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ4/translations/it_IT/driver-api/serial/serial-iso7816”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)”}”(hhh]”hŒJapanese”…””}”hhZsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ4/translations/ja_JP/driver-api/serial/serial-iso7816”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)”}”(hhh]”hŒKorean”…””}”hhnsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ4/translations/ko_KR/driver-api/serial/serial-iso7816”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)”}”(hhh]”hŒSpanish”…””}”hh‚sbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ4/translations/sp_SP/driver-api/serial/serial-iso7816”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubeh}”(h]”h ]”h"]”h$]”h&]”Œcurrent_language”ŒEnglish”uh1h hhŒ _document”hŒsource”NŒline”NubhŒsection”“”)”}”(hhh]”(hŒtitle”“”)”}”(hŒISO7816 Serial Communications”h]”hŒISO7816 Serial Communications”…””}”(hh¨hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h¦hh£hžhhŸŒN/var/lib/git/docbuild/linux/Documentation/driver-api/serial/serial-iso7816.rst”h Kubh¢)”}”(hhh]”(h§)”}”(hŒ1. Introduction”h]”hŒ1. Introduction”…””}”(hhºhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h¦hh·hžhhŸh¶h KubhŒ block_quote”“”)”}”(hŒjISO/IEC7816 is a series of standards specifying integrated circuit cards (ICC) also known as smart cards. ”h]”hŒ paragraph”“”)”}”(hŒiISO/IEC7816 is a series of standards specifying integrated circuit cards (ICC) also known as smart cards.”h]”hŒiISO/IEC7816 is a series of standards specifying integrated circuit cards (ICC) also known as smart cards.”…””}”(hhÐhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÎhŸh¶h KhhÊubah}”(h]”h ]”h"]”h$]”h&]”uh1hÈhŸh¶h Khh·hžhubeh}”(h]”Œ introduction”ah ]”h"]”Œ1. introduction”ah$]”h&]”uh1h¡hh£hžhhŸh¶h Kubh¢)”}”(hhh]”(h§)”}”(hŒ"2. Hardware-related considerations”h]”hŒ"2. Hardware-related considerations”…””}”(hhïhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h¦hhìhžhhŸh¶h K ubhÉ)”}”(hXWSome CPUs/UARTs (e.g., Microchip AT91) contain a built-in mode capable of handling communication with a smart card. For these microcontrollers, the Linux driver should be made capable of working in both modes, and proper ioctls (see later) should be made available at user-level to allow switching from one mode to the other, and vice versa. ”h]”(hÏ)”}”(hŒsSome CPUs/UARTs (e.g., Microchip AT91) contain a built-in mode capable of handling communication with a smart card.”h]”hŒsSome CPUs/UARTs (e.g., Microchip AT91) contain a built-in mode capable of handling communication with a smart card.”…””}”(hjhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÎhŸh¶h KhhýubhÏ)”}”(hŒáFor these microcontrollers, the Linux driver should be made capable of working in both modes, and proper ioctls (see later) should be made available at user-level to allow switching from one mode to the other, and vice versa.”h]”hŒáFor these microcontrollers, the Linux driver should be made capable of working in both modes, and proper ioctls (see later) should be made available at user-level to allow switching from one mode to the other, and vice versa.”…””}”(hjhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÎhŸh¶h Khhýubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÈhŸh¶h Khhìhžhubeh}”(h]”Œhardware-related-considerations”ah ]”h"]”Œ"2. hardware-related considerations”ah$]”h&]”uh1h¡hh£hžhhŸh¶h K ubh¢)”}”(hhh]”(h§)”}”(hŒ23. Data Structures Already Available in the Kernel”h]”hŒ23. Data Structures Already Available in the Kernel”…””}”(hj.hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h¦hj+hžhhŸh¶h KubhÉ)”}”(hXThe Linux kernel provides the serial_iso7816 structure (see [1]) to handle ISO7816 communications. This data structure is used to set and configure ISO7816 parameters in ioctls. Any driver for devices capable of working both as RS232 and ISO7816 should implement the iso7816_config callback in the uart_port structure. The serial_core calls iso7816_config to do the device specific part in response to TIOCGISO7816 and TIOCSISO7816 ioctls (see below). The iso7816_config callback receives a pointer to struct serial_iso7816. ”h]”(hÏ)”}”(hŒ±The Linux kernel provides the serial_iso7816 structure (see [1]) to handle ISO7816 communications. This data structure is used to set and configure ISO7816 parameters in ioctls.”h]”hŒ±The Linux kernel provides the serial_iso7816 structure (see [1]) to handle ISO7816 communications. This data structure is used to set and configure ISO7816 parameters in ioctls.”…””}”(hj@hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÎhŸh¶h Khj<ubhÏ)”}”(hXZAny driver for devices capable of working both as RS232 and ISO7816 should implement the iso7816_config callback in the uart_port structure. The serial_core calls iso7816_config to do the device specific part in response to TIOCGISO7816 and TIOCSISO7816 ioctls (see below). The iso7816_config callback receives a pointer to struct serial_iso7816.”h]”hXZAny driver for devices capable of working both as RS232 and ISO7816 should implement the iso7816_config callback in the uart_port structure. The serial_core calls iso7816_config to do the device specific part in response to TIOCGISO7816 and TIOCSISO7816 ioctls (see below). The iso7816_config callback receives a pointer to struct serial_iso7816.”…””}”(hjNhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÎhŸh¶h Khj<ubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÈhŸh¶h Khj+hžhubeh}”(h]”Œ/data-structures-already-available-in-the-kernel”ah ]”h"]”Œ23. data structures already available in the kernel”ah$]”h&]”uh1h¡hh£hžhhŸh¶h Kubh¢)”}”(hhh]”(h§)”}”(hŒ4. Usage from user-level”h]”hŒ4. Usage from user-level”…””}”(hjmhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h¦hjjhžhhŸh¶h K$ubhÉ)”}”(hX`From user-level, ISO7816 configuration can be get/set using the previous ioctls. For instance, to set ISO7816 you can use the following code:: #include /* Include definition for ISO7816 ioctls: TIOCSISO7816 and TIOCGISO7816 */ #include /* Open your specific device (e.g., /dev/mydevice): */ int fd = open ("/dev/mydevice", O_RDWR); if (fd < 0) { /* Error handling. See errno. */ } struct serial_iso7816 iso7816conf; /* Reserved fields as to be zeroed */ memset(&iso7816conf, 0, sizeof(iso7816conf)); /* Enable ISO7816 mode: */ iso7816conf.flags |= SER_ISO7816_ENABLED; /* Select the protocol: */ /* T=0 */ iso7816conf.flags |= SER_ISO7816_T(0); /* or T=1 */ iso7816conf.flags |= SER_ISO7816_T(1); /* Set the guard time: */ iso7816conf.tg = 2; /* Set the clock frequency*/ iso7816conf.clk = 3571200; /* Set transmission factors: */ iso7816conf.sc_fi = 372; iso7816conf.sc_di = 1; if (ioctl(fd_usart, TIOCSISO7816, &iso7816conf) < 0) { /* Error handling. See errno. */ } /* Use read() and write() syscalls here... */ /* Close the device when finished: */ if (close (fd) < 0) { /* Error handling. See errno. */ } ”h]”(hÏ)”}”(hŒŽFrom user-level, ISO7816 configuration can be get/set using the previous ioctls. For instance, to set ISO7816 you can use the following code::”h]”hŒFrom user-level, ISO7816 configuration can be get/set using the previous ioctls. For instance, to set ISO7816 you can use the following code:”…””}”(hjhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÎhŸh¶h K&hj{ubhŒ literal_block”“”)”}”(hX #include /* Include definition for ISO7816 ioctls: TIOCSISO7816 and TIOCGISO7816 */ #include /* Open your specific device (e.g., /dev/mydevice): */ int fd = open ("/dev/mydevice", O_RDWR); if (fd < 0) { /* Error handling. See errno. */ } struct serial_iso7816 iso7816conf; /* Reserved fields as to be zeroed */ memset(&iso7816conf, 0, sizeof(iso7816conf)); /* Enable ISO7816 mode: */ iso7816conf.flags |= SER_ISO7816_ENABLED; /* Select the protocol: */ /* T=0 */ iso7816conf.flags |= SER_ISO7816_T(0); /* or T=1 */ iso7816conf.flags |= SER_ISO7816_T(1); /* Set the guard time: */ iso7816conf.tg = 2; /* Set the clock frequency*/ iso7816conf.clk = 3571200; /* Set transmission factors: */ iso7816conf.sc_fi = 372; iso7816conf.sc_di = 1; if (ioctl(fd_usart, TIOCSISO7816, &iso7816conf) < 0) { /* Error handling. See errno. */ } /* Use read() and write() syscalls here... */ /* Close the device when finished: */ if (close (fd) < 0) { /* Error handling. See errno. */ }”h]”hX #include /* Include definition for ISO7816 ioctls: TIOCSISO7816 and TIOCGISO7816 */ #include /* Open your specific device (e.g., /dev/mydevice): */ int fd = open ("/dev/mydevice", O_RDWR); if (fd < 0) { /* Error handling. See errno. */ } struct serial_iso7816 iso7816conf; /* Reserved fields as to be zeroed */ memset(&iso7816conf, 0, sizeof(iso7816conf)); /* Enable ISO7816 mode: */ iso7816conf.flags |= SER_ISO7816_ENABLED; /* Select the protocol: */ /* T=0 */ iso7816conf.flags |= SER_ISO7816_T(0); /* or T=1 */ iso7816conf.flags |= SER_ISO7816_T(1); /* Set the guard time: */ iso7816conf.tg = 2; /* Set the clock frequency*/ iso7816conf.clk = 3571200; /* Set transmission factors: */ iso7816conf.sc_fi = 372; iso7816conf.sc_di = 1; if (ioctl(fd_usart, TIOCSISO7816, &iso7816conf) < 0) { /* Error handling. See errno. */ } /* Use read() and write() syscalls here... */ /* Close the device when finished: */ if (close (fd) < 0) { /* Error handling. See errno. */ }”…””}”hjsbah}”(h]”h ]”h"]”h$]”h&]”Œ xml:space”Œpreserve”uh1jhŸh¶h K)hj{ubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÈhŸh¶h K&hjjhžhubeh}”(h]”Œusage-from-user-level”ah ]”h"]”Œ4. usage from user-level”ah$]”h&]”uh1h¡hh£hžhhŸh¶h K$ubh¢)”}”(hhh]”(h§)”}”(hŒ 5. References”h]”hŒ 5. References”…””}”(hj°hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h¦hj­hžhhŸh¶h KXubhÉ)”}”(hŒ"[1] include/uapi/linux/serial.h”h]”hÏ)”}”(hjÀh]”hŒ"[1] include/uapi/linux/serial.h”…””}”(hjÂhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÎhŸh¶h KZhj¾ubah}”(h]”h ]”h"]”h$]”h&]”uh1hÈhŸh¶h KZhj­hžhubeh}”(h]”Œ references”ah ]”h"]”Œ 5. references”ah$]”h&]”uh1h¡hh£hžhhŸh¶h KXubeh}”(h]”Œiso7816-serial-communications”ah ]”h"]”Œiso7816 serial communications”ah$]”h&]”uh1h¡hhhžhhŸh¶h Kubeh}”(h]”h ]”h"]”h$]”h&]”Œsource”h¶uh1hŒcurrent_source”NŒ current_line”NŒsettings”Œdocutils.frontend”ŒValues”“”)”}”(h¦NŒ generator”NŒ datestamp”NŒ source_link”NŒ source_url”NŒ toc_backlinks”Œentry”Œfootnote_backlinks”KŒ sectnum_xform”KŒstrip_comments”NŒstrip_elements_with_classes”NŒ strip_classes”NŒ report_level”KŒ halt_level”KŒexit_status_level”KŒdebug”NŒwarning_stream”NŒ traceback”ˆŒinput_encoding”Œ utf-8-sig”Œinput_encoding_error_handler”Œstrict”Œoutput_encoding”Œutf-8”Œoutput_encoding_error_handler”jŒerror_encoding”Œutf-8”Œerror_encoding_error_handler”Œbackslashreplace”Œ language_code”Œen”Œrecord_dependencies”NŒconfig”NŒ id_prefix”hŒauto_id_prefix”Œid”Œ dump_settings”NŒdump_internals”NŒdump_transforms”NŒdump_pseudo_xml”NŒexpose_internals”NŒstrict_visitor”NŒ_disable_config”NŒ_source”h¶Œ _destination”NŒ _config_files”]”Œ7/var/lib/git/docbuild/linux/Documentation/docutils.conf”aŒfile_insertion_enabled”ˆŒ raw_enabled”KŒline_length_limit”M'Œpep_references”NŒ pep_base_url”Œhttps://peps.python.org/”Œpep_file_url_template”Œpep-%04d”Œrfc_references”NŒ rfc_base_url”Œ&https://datatracker.ietf.org/doc/html/”Œ tab_width”KŒtrim_footnote_reference_space”‰Œsyntax_highlight”Œlong”Œ smart_quotes”ˆŒsmartquotes_locales”]”Œcharacter_level_inline_markup”‰Œdoctitle_xform”‰Œ docinfo_xform”KŒsectsubtitle_xform”‰Œ image_loading”Œlink”Œembed_stylesheet”‰Œcloak_email_addresses”ˆŒsection_self_link”‰Œenv”NubŒreporter”NŒindirect_targets”]”Œsubstitution_defs”}”Œsubstitution_names”}”Œrefnames”}”Œrefids”}”Œnameids”}”(jâjßhéhæj(j%jgjdjªj§jÚj×uŒ nametypes”}”(jâ‰hé‰j(‰jg‰jª‰jÚ‰uh}”(jßh£hæh·j%hìjdj+j§jjj×j­uŒ footnote_refs”}”Œ citation_refs”}”Œ autofootnotes”]”Œautofootnote_refs”]”Œsymbol_footnotes”]”Œsymbol_footnote_refs”]”Œ footnotes”]”Œ citations”]”Œautofootnote_start”KŒsymbol_footnote_start”KŒ id_counter”Œ collections”ŒCounter”“”}”…”R”Œparse_messages”]”Œtransform_messages”]”Œ transformer”NŒ include_log”]”Œ decoration”Nhžhub.