€•5Œ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ŒPortuguese (Brazilian)”…””}”hh‚sbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ4/translations/pt_BR/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”…””}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhjh²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´Khjubhã)”}”(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.”…””}”(hj#h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hâh³hÊh´Khjubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´Khjh²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”…””}”(hjBh²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.”…””}”(hjTh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hâh³hÊh´KhjPubhã)”}”(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.”…””}”(hjbh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hâh³hÊh´KhjPubeh}”(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”…””}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhj~h²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:”…””}”(hj“h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hâh³hÊh´K&hjubhŒ 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. */ }”…””}”hj£sbah}”(h]”h ]”h"]”h$]”h&]”Œ xml:space”Œpreserve”uh1j¡h³hÊh´K)hjubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´K&hj~h²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<j9j{jxj¾j»jîjëuŒ nametypes”}”(jö‰hý‰j<‰j{‰j¾‰jî‰uh}”(jóh·húhËj9jjxj?j»j~jë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.