Difference between revisions of "EIA-ASCII-ISO encoding"
(→run) |
(→run miniterm) |
||
(30 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
= trivia = | = trivia = | ||
* old NC-maschines might use EIA or ISO 'paper-tape' encoding on serial-communication | * old NC-maschines might use EIA or ISO 'paper-tape' encoding on serial-communication | ||
+ | |||
+ | == links == | ||
* https://www.grecosystems.com/wp-content/uploads/2015/04/CNCMinifileOM.pdf (appendix 'F', page 61-62) | * https://www.grecosystems.com/wp-content/uploads/2015/04/CNCMinifileOM.pdf (appendix 'F', page 61-62) | ||
− | + | * https://i-logic.com/serial/punchholes.htm | |
− | char EIA ASCII ISO | + | * https://i-logic.com/serial/eia.htm |
− | + | * https://books.google.de/books?id=4bJJbIaOgcYC&lpg=PA12&ots=pwQCwkgdWm&dq=iso%20eia%20paper%20tape%20cnc&hl=de&pg=PA16#v=onepage&q=iso%20eia%20paper%20tape%20cnc&f=false | |
− | + | ||
− | + | == conversion charts == | |
− | + | ||
− | + | {| class="wikitable sortable" | |
− | + | |- | |
− | + | !char||EIA||||ASCII||||ISO||||||remark | |
− | + | |- | |
− | + | !||(hex)||(dec)||(hex)||(dec)||(hex)||(dec)|||| | |
− | + | |- | |
− | + | |BS||2A||42||08||8||88||136||BACKSPACE|| | |
− | + | |- | |
− | + | |HT||33||51||09||9||09||9||HORIZONTAL TABULATION|| | |
− | + | |- | |
− | + | |LF||80||128||0A||10||0A||10||LINE FEED||EOB | |
− | + | |- | |
− | + | |CR||||||0D||13||8D||141||CARRIAGE RETURN|| | |
− | + | |- | |
− | + | |||10||16||20||32||A0||160||SPACE|| | |
− | + | |- | |
− | + | | $||||||24||36||24||36||DOLLAR SIGN|| | |
− | + | |- | |
− | + | | %||5B||91||25||37||A5||165||PERCENT SIGN||EOR – Rewind Stop in ASCII | |
− | + | |- | |
− | + | | &||0E||14||26||38||A6||166||AMPERSAND|| | |
− | + | |- | |
− | + | | (||1A||26||28||40||28||40||LEFT PARENTHESIS|| | |
− | + | |- | |
− | + | | )||4A||74||29||41||A9||169||RIGHT PARENTHESIS|| | |
− | + | |- | |
− | + | | +||70||112||2B||43||2B||43||PLUS SIGN|| | |
− | + | |- | |
− | + | | ,||3B||59||2C||44||||||COMMA|| | |
− | + | |- | |
− | + | | -||40||64||2D||45||2D||45||HYPHEN-MINUS|| | |
− | + | |- | |
− | + | | .||6B||107||2E||46||2E||46||FULL STOP|| | |
− | + | |- | |
− | + | | /||31||49||2F||47||AF||175||SOLIDUS|| | |
− | + | |- | |
− | + | |0||20||32||30||48||30||48||DIGIT ZERO|| | |
− | + | |- | |
− | + | |1||01||1||31||49||B1||177||DIGIT ONE|| | |
− | + | |- | |
− | + | |2||02||2||32||50||B2||178||DIGIT TWO|| | |
− | + | |- | |
− | + | |3||13||19||33||51||33||51||DIGIT THREE|| | |
− | + | |- | |
− | + | |4||04||4||34||52||B4||180||DIGIT FOUR|| | |
− | + | |- | |
− | + | |5||15||21||35||53||35||53||DIGIT FIVE|| | |
− | + | |- | |
− | + | |6||16||22||36||54||36||54||DIGIT SIX|| | |
− | + | |- | |
− | + | |7||07||7||37||55||B7||183||DIGIT SEVEN|| | |
+ | |- | ||
+ | |8||08||8||38||56||B8||184||DIGIT EIGHT|| | ||
+ | |- | ||
+ | |9||19||25||39||57||39||57||DIGIT NINE|| | ||
+ | |- | ||
+ | | :||||||3A||58||3A||58||COLON|| | ||
+ | |- | ||
+ | | =||||||3D||61||BD||189||EQUALS SIGN|| | ||
+ | |- | ||
+ | | @||||||40||64||C0||192||COMMERCIAL AT|| | ||
+ | |- | ||
+ | | A||61||97||41||65||41||65||LATIN CAPITAL LETTER A|| | ||
+ | |- | ||
+ | | B||62||98||42||66||42||66||LATIN CAPITAL LETTER B|| | ||
+ | |- | ||
+ | | C||73||115||43||67||C3||195||LATIN CAPITAL LETTER C|| | ||
+ | |- | ||
+ | | D||64||100||44||68||44||68||LATIN CAPITAL LETTER D|| | ||
+ | |- | ||
+ | | E||75||117||45||69||C5||197||LATIN CAPITAL LETTER E|| | ||
+ | |- | ||
+ | | F||76||118||46||70||C6||198||LATIN CAPITAL LETTER F|| | ||
+ | |- | ||
+ | | G||67||103||47||71||47||71||LATIN CAPITAL LETTER G|| | ||
+ | |- | ||
+ | | H||68||104||48||72||48||72||LATIN CAPITAL LETTER H|| | ||
+ | |- | ||
+ | | I||79||121||49||73||C9||201||LATIN CAPITAL LETTER I|| | ||
+ | |- | ||
+ | | J||51||81||4A||74||CA||202||LATIN CAPITAL LETTER J|| | ||
+ | |- | ||
+ | | K||52||82||4B||75||4B||75||LATIN CAPITAL LETTER K|| | ||
+ | |- | ||
+ | | L||43||67||4C||76||CC||204||LATIN CAPITAL LETTER L|| | ||
+ | |- | ||
+ | | M||54||84||4D||77||4D||77||LATIN CAPITAL LETTER M|| | ||
+ | |- | ||
+ | | N||45||69||4E||78||4E||78||LATIN CAPITAL LETTER N|| | ||
+ | |- | ||
+ | | O||46||70||4F||79||CF||207||LATIN CAPITAL LETTER O|| | ||
+ | |- | ||
+ | | P||57||87||50||80||50||80||LATIN CAPITAL LETTER P|| | ||
+ | |- | ||
+ | | Q||58||88||51||81||D1||209||LATIN CAPITAL LETTER Q|| | ||
+ | |- | ||
+ | | R||49||73||52||82||D2||210||LATIN CAPITAL LETTER R|| | ||
+ | |- | ||
+ | | S||32||50||53||83||53||83||LATIN CAPITAL LETTER S|| | ||
+ | |- | ||
+ | | T||23||35||54||84||D4||212||LATIN CAPITAL LETTER T|| | ||
+ | |- | ||
+ | | U||34||52||55||85||55||85||LATIN CAPITAL LETTER U|| | ||
+ | |- | ||
+ | | V||25||37||56||86||56||86||LATIN CAPITAL LETTER V|| | ||
+ | |- | ||
+ | | W||26||38||57||87||D7||215||LATIN CAPITAL LETTER W|| | ||
+ | |- | ||
+ | | X||37||55||58||88||D8||216||LATIN CAPITAL LETTER X|| | ||
+ | |- | ||
+ | | Y||38||56||59||89||59||89||LATIN CAPITAL LETTER Y|| | ||
+ | |- | ||
+ | | Z||29||41||5A||90||5A||90||LATIN CAPITAL LETTER Z|| | ||
+ | |- | ||
+ | |} | ||
= pySerial = | = pySerial = | ||
Line 75: | Line 141: | ||
* <pre>sudo cp usr/lip/python2.7/encodings/hp_roman8.py usr/lip/python2.7/encodings/iso_paper.py</pre> | * <pre>sudo cp usr/lip/python2.7/encodings/hp_roman8.py usr/lip/python2.7/encodings/iso_paper.py</pre> | ||
* edit <b>iso_paper.py</b> as needed ... | * edit <b>iso_paper.py</b> as needed ... | ||
+ | <pre> | ||
+ | """ Python Character Mapping Codec 'ISO_paper tape' | ||
+ | see https://bastelbude.grade.de/mediawiki/index.php?title=EIA-ASCII-ISO_encoding for details | ||
+ | valid: | ||
+ | [BACKSPACE] [HORIZONTAL TABULATION] [LINE FEED] [CARRIAGE RETURN] [SPACE] | ||
+ | $ % & ( ) + - . / | ||
+ | 0 1 2 3 4 5 6 7 8 9 | ||
+ | : = @ | ||
+ | A B C D E F G H I J K L M N O P Q R S T U V W X Y Z | ||
+ | """#" | ||
+ | |||
+ | import codecs | ||
+ | |||
+ | ### Codec APIs | ||
+ | |||
+ | class Codec(codecs.Codec): | ||
+ | |||
+ | def encode(self,input,errors='strict'): | ||
+ | return codecs.charmap_encode(input,errors,encoding_map) | ||
+ | |||
+ | def decode(self,input,errors='strict'): | ||
+ | return codecs.charmap_decode(input,errors,decoding_map) | ||
+ | |||
+ | class IncrementalEncoder(codecs.IncrementalEncoder): | ||
+ | def encode(self, input, final=False): | ||
+ | return codecs.charmap_encode(input,self.errors,encoding_map)[0] | ||
+ | |||
+ | class IncrementalDecoder(codecs.IncrementalDecoder): | ||
+ | def decode(self, input, final=False): | ||
+ | return codecs.charmap_decode(input,self.errors,decoding_map)[0] | ||
+ | |||
+ | class StreamWriter(Codec,codecs.StreamWriter): | ||
+ | pass | ||
+ | |||
+ | class StreamReader(Codec,codecs.StreamReader): | ||
+ | pass | ||
+ | |||
+ | ### encodings module API | ||
+ | |||
+ | def getregentry(): | ||
+ | return codecs.CodecInfo( | ||
+ | name='iso-paper', | ||
+ | encode=Codec().encode, | ||
+ | decode=Codec().decode, | ||
+ | incrementalencoder=IncrementalEncoder, | ||
+ | incrementaldecoder=IncrementalDecoder, | ||
+ | streamwriter=StreamWriter, | ||
+ | streamreader=StreamReader, | ||
+ | ) | ||
+ | |||
+ | ### Decoding Map | ||
+ | |||
+ | decoding_map = codecs.make_identity_dict(range(256)) | ||
+ | decoding_map.update({ | ||
+ | 0x0008: None, # needs to be set for encoding_map | ||
+ | 0x000d: None, # needs to be set for encoding_map | ||
+ | 0x0020: None, # needs to be set for encoding_map | ||
+ | 0x0025: None, # needs to be set for encoding_map | ||
+ | 0x0026: None, # needs to be set for encoding_map | ||
+ | 0x0029: None, # needs to be set for encoding_map | ||
+ | 0x002c: None, # needs to be set for encoding_map | ||
+ | 0x002f: None, # needs to be set for encoding_map | ||
+ | 0x0031: None, # needs to be set for encoding_map | ||
+ | 0x0032: None, # needs to be set for encoding_map | ||
+ | 0x0034: None, # needs to be set for encoding_map | ||
+ | 0x0037: None, # needs to be set for encoding_map | ||
+ | 0x0038: None, # needs to be set for encoding_map | ||
+ | 0x003d: None, # needs to be set for encoding_map | ||
+ | 0x0040: None, # needs to be set for encoding_map | ||
+ | 0x0043: None, # needs to be set for encoding_map | ||
+ | 0x0045: None, # needs to be set for encoding_map | ||
+ | 0x0046: None, # needs to be set for encoding_map | ||
+ | 0x0049: None, # needs to be set for encoding_map | ||
+ | 0x004a: None, # needs to be set for encoding_map | ||
+ | 0x004c: None, # needs to be set for encoding_map | ||
+ | 0x004f: None, # needs to be set for encoding_map | ||
+ | 0x0051: None, # needs to be set for encoding_map | ||
+ | 0x0052: None, # needs to be set for encoding_map | ||
+ | 0x0054: None, # needs to be set for encoding_map | ||
+ | 0x0057: None, # needs to be set for encoding_map | ||
+ | 0x0058: None, # needs to be set for encoding_map | ||
+ | 0x0088: 0x0008, # BACKSPACE | ||
+ | 0x0009: 0x0009, # HORIZONTAL TABULATION | ||
+ | 0x000A: 0x000A, # LINE FEED | ||
+ | 0x008D: 0x000D, # CARRIAGE RETURN | ||
+ | 0x00A0: 0x0020, # SPACE | ||
+ | 0x0024: 0x0024, # DOLLAR SIGN | ||
+ | 0x00A5: 0x0025, # PERCENT SIGN | ||
+ | 0x00A6: 0x0026, # AMPERSAND | ||
+ | 0x0028: 0x0028, # LEFT PARENTHESIS | ||
+ | 0x00A9: 0x0029, # RIGHT PARENTHESIS | ||
+ | 0x002B: 0x002B, # PLUS SIGN | ||
+ | 0x002D: 0x002D, # HYPHEN-MINUS | ||
+ | 0x002E: 0x002E, # FULL STOP | ||
+ | 0x00AF: 0x002F, # SOLIDUS | ||
+ | 0x0030: 0x0030, # DIGIT ZERO | ||
+ | 0x00B1: 0x0031, # DIGIT ONE | ||
+ | 0x00B2: 0x0032, # DIGIT TWO | ||
+ | 0x0033: 0x0033, # DIGIT THREE | ||
+ | 0x00B4: 0x0034, # DIGIT FOUR | ||
+ | 0x0035: 0x0035, # DIGIT FIVE | ||
+ | 0x0036: 0x0036, # DIGIT SIX | ||
+ | 0x00B7: 0x0037, # DIGIT SEVEN | ||
+ | 0x00B8: 0x0038, # DIGIT EIGHT | ||
+ | 0x0039: 0x0039, # DIGIT NINE | ||
+ | 0x003A: 0x003A, # COLON | ||
+ | 0x00BD: 0x003D, # EQUALS SIGN | ||
+ | 0x00C0: 0x0040, # COMMERCIAL AT | ||
+ | 0x0041: 0x0041, # LATIN CAPITAL LETTER A | ||
+ | 0x0042: 0x0042, # LATIN CAPITAL LETTER B | ||
+ | 0x00C3: 0x0043, # LATIN CAPITAL LETTER C | ||
+ | 0x0044: 0x0044, # LATIN CAPITAL LETTER D | ||
+ | 0x00C5: 0x0045, # LATIN CAPITAL LETTER E | ||
+ | 0x00C6: 0x0046, # LATIN CAPITAL LETTER F | ||
+ | 0x0047: 0x0047, # LATIN CAPITAL LETTER G | ||
+ | 0x0048: 0x0048, # LATIN CAPITAL LETTER H | ||
+ | 0x00C9: 0x0049, # LATIN CAPITAL LETTER I | ||
+ | 0x00CA: 0x004A, # LATIN CAPITAL LETTER J | ||
+ | 0x004B: 0x004B, # LATIN CAPITAL LETTER K | ||
+ | 0x00CC: 0x004C, # LATIN CAPITAL LETTER L | ||
+ | 0x004D: 0x004D, # LATIN CAPITAL LETTER M | ||
+ | 0x004E: 0x004E, # LATIN CAPITAL LETTER N | ||
+ | 0x00CF: 0x004F, # LATIN CAPITAL LETTER O | ||
+ | 0x0050: 0x0050, # LATIN CAPITAL LETTER P | ||
+ | 0x00D1: 0x0051, # LATIN CAPITAL LETTER Q | ||
+ | 0x00D2: 0x0052, # LATIN CAPITAL LETTER R | ||
+ | 0x0053: 0x0053, # LATIN CAPITAL LETTER S | ||
+ | 0x00D4: 0x0054, # LATIN CAPITAL LETTER T | ||
+ | 0x0055: 0x0055, # LATIN CAPITAL LETTER U | ||
+ | 0x0056: 0x0056, # LATIN CAPITAL LETTER V | ||
+ | 0x00D7: 0x0057, # LATIN CAPITAL LETTER W | ||
+ | 0x00D8: 0x0058, # LATIN CAPITAL LETTER X | ||
+ | 0x0059: 0x0059, # LATIN CAPITAL LETTER Y | ||
+ | 0x005A: 0x005A, # LATIN CAPITAL LETTER Z | ||
+ | }) | ||
+ | |||
+ | ### Encoding Map | ||
+ | |||
+ | encoding_map = codecs.make_encoding_map(decoding_map) | ||
+ | |||
+ | </pre> | ||
+ | |||
+ | * <pre>sudo cp usr/lip/python2.7/encodings/hp_roman8.py usr/lip/python2.7/encodings/eia_paper.py</pre> | ||
+ | * edit <b>eia_paper.py</b> as needed ... | ||
+ | |||
+ | <pre> | ||
+ | """ Python Character Mapping Codec 'EIA_paper tape' | ||
+ | see https://bastelbude.grade.de/mediawiki/index.php?title=EIA-ASCII-ISO_encoding for details | ||
+ | valid: | ||
+ | [BACKSPACE] [HORIZONTAL TABULATION] [LINE FEED] [SPACE] | ||
+ | % & ( ) + , - . / | ||
+ | 0 1 2 3 4 5 6 7 8 9 | ||
+ | A B C D E F G H I J K L M N O P Q R S T U V W X Y Z | ||
+ | """#" | ||
+ | |||
+ | import codecs | ||
+ | |||
+ | ### Codec APIs | ||
+ | |||
+ | class Codec(codecs.Codec): | ||
+ | |||
+ | def encode(self,input,errors='strict'): | ||
+ | return codecs.charmap_encode(input,errors,encoding_map) | ||
+ | |||
+ | def decode(self,input,errors='strict'): | ||
+ | return codecs.charmap_decode(input,errors,decoding_map) | ||
+ | |||
+ | class IncrementalEncoder(codecs.IncrementalEncoder): | ||
+ | def encode(self, input, final=False): | ||
+ | return codecs.charmap_encode(input,self.errors,encoding_map)[0] | ||
+ | |||
+ | class IncrementalDecoder(codecs.IncrementalDecoder): | ||
+ | def decode(self, input, final=False): | ||
+ | return codecs.charmap_decode(input,self.errors,decoding_map)[0] | ||
+ | |||
+ | class StreamWriter(Codec,codecs.StreamWriter): | ||
+ | pass | ||
+ | |||
+ | class StreamReader(Codec,codecs.StreamReader): | ||
+ | pass | ||
+ | |||
+ | ### encodings module API | ||
+ | |||
+ | def getregentry(): | ||
+ | return codecs.CodecInfo( | ||
+ | name='eia-paper', | ||
+ | encode=Codec().encode, | ||
+ | decode=Codec().decode, | ||
+ | incrementalencoder=IncrementalEncoder, | ||
+ | incrementaldecoder=IncrementalDecoder, | ||
+ | streamwriter=StreamWriter, | ||
+ | streamreader=StreamReader, | ||
+ | ) | ||
+ | |||
+ | ### Decoding Map | ||
+ | |||
+ | decoding_map = codecs.make_identity_dict(range(256)) | ||
+ | decoding_map.update({ | ||
+ | 0x0009: None, # [9]needs to be set for encoding_map | ||
+ | 0x000A: None, # [10]needs to be set for encoding_map | ||
+ | 0x0028: None, # [40]needs to be set for encoding_map | ||
+ | 0x002B: None, # [43]needs to be set for encoding_map | ||
+ | 0x002C: None, # [44]needs to be set for encoding_map | ||
+ | 0x002D: None, # [45]needs to be set for encoding_map | ||
+ | 0x002E: None, # [46]needs to be set for encoding_map | ||
+ | 0x002F: None, # [47]needs to be set for encoding_map | ||
+ | 0x0030: None, # [48]needs to be set for encoding_map | ||
+ | 0x0035: None, # [53]needs to be set for encoding_map | ||
+ | 0x0036: None, # [54]needs to be set for encoding_map | ||
+ | 0x0039: None, # [57]needs to be set for encoding_map | ||
+ | 0x003A: None, # [58]needs to be set for encoding_map | ||
+ | 0x0041: None, # [65]needs to be set for encoding_map | ||
+ | 0x0042: None, # [66]needs to be set for encoding_map | ||
+ | 0x0044: None, # [68]needs to be set for encoding_map | ||
+ | 0x0047: None, # [71]needs to be set for encoding_map | ||
+ | 0x0048: None, # [72]needs to be set for encoding_map | ||
+ | 0x004B: None, # [75]needs to be set for encoding_map | ||
+ | 0x004C: None, # [76]needs to be set for encoding_map | ||
+ | 0x004D: None, # [77]needs to be set for encoding_map | ||
+ | 0x004E: None, # [78]needs to be set for encoding_map | ||
+ | 0x004F: None, # [79]needs to be set for encoding_map | ||
+ | 0x0050: None, # [80]needs to be set for encoding_map | ||
+ | 0x0053: None, # [83]needs to be set for encoding_map | ||
+ | 0x0055: None, # [85]needs to be set for encoding_map | ||
+ | 0x0056: None, # [86]needs to be set for encoding_map | ||
+ | 0x0059: None, # [89]needs to be set for encoding_map | ||
+ | 0x005A: None, # [90]needs to be set for encoding_map | ||
+ | 0x002A: 0x0008, # BACKSPACE | ||
+ | 0x0033: 0x0009, # HORIZONTAL TABULATION | ||
+ | 0x0080: 0x000A, # LINE FEED (EOB) | ||
+ | 0x0010: 0x0020, # SPACE | ||
+ | 0x005B: 0x0025, # PERCENT SIGN | ||
+ | 0x000E: 0x0026, # AMPERSAND | ||
+ | 0x001A: 0x0028, # LEFT PARENTHESIS | ||
+ | 0x004A: 0x0029, # RIGHT PARENTHESIS | ||
+ | 0x0070: 0x002B, # PLUS SIGN | ||
+ | 0x003B: 0x002C, # COMMA | ||
+ | 0x0040: 0x002D, # HYPHEN-MINUS | ||
+ | 0x006B: 0x002E, # FULL STOP | ||
+ | 0x0031: 0x002F, # SOLIDUS | ||
+ | 0x0020: 0x0030, # DIGIT ZERO | ||
+ | 0x0001: 0x0031, # DIGIT ONE | ||
+ | 0x0002: 0x0032, # DIGIT TWO | ||
+ | 0x0013: 0x0033, # DIGIT THREE | ||
+ | 0x0004: 0x0034, # DIGIT FOUR | ||
+ | 0x0015: 0x0035, # DIGIT FIVE | ||
+ | 0x0016: 0x0036, # DIGIT SIX | ||
+ | 0x0007: 0x0037, # DIGIT SEVEN | ||
+ | 0x0008: 0x0038, # DIGIT EIGHT | ||
+ | 0x0019: 0x0039, # DIGIT NINE | ||
+ | 0x0061: 0x0041, # LATIN CAPITAL LETTER A | ||
+ | 0x0062: 0x0042, # LATIN CAPITAL LETTER B | ||
+ | 0x0073: 0x0043, # LATIN CAPITAL LETTER C | ||
+ | 0x0064: 0x0044, # LATIN CAPITAL LETTER D | ||
+ | 0x0075: 0x0045, # LATIN CAPITAL LETTER E | ||
+ | 0x0076: 0x0046, # LATIN CAPITAL LETTER F | ||
+ | 0x0067: 0x0047, # LATIN CAPITAL LETTER G | ||
+ | 0x0068: 0x0048, # LATIN CAPITAL LETTER H | ||
+ | 0x0079: 0x0049, # LATIN CAPITAL LETTER I | ||
+ | 0x0051: 0x004A, # LATIN CAPITAL LETTER J | ||
+ | 0x0052: 0x004B, # LATIN CAPITAL LETTER K | ||
+ | 0x0043: 0x004C, # LATIN CAPITAL LETTER L | ||
+ | 0x0054: 0x004D, # LATIN CAPITAL LETTER M | ||
+ | 0x0045: 0x004E, # LATIN CAPITAL LETTER N | ||
+ | 0x0046: 0x004F, # LATIN CAPITAL LETTER O | ||
+ | 0x0057: 0x0050, # LATIN CAPITAL LETTER P | ||
+ | 0x0058: 0x0051, # LATIN CAPITAL LETTER Q | ||
+ | 0x0049: 0x0052, # LATIN CAPITAL LETTER R | ||
+ | 0x0032: 0x0053, # LATIN CAPITAL LETTER S | ||
+ | 0x0023: 0x0054, # LATIN CAPITAL LETTER T | ||
+ | 0x0034: 0x0055, # LATIN CAPITAL LETTER U | ||
+ | 0x0025: 0x0056, # LATIN CAPITAL LETTER V | ||
+ | 0x0026: 0x0057, # LATIN CAPITAL LETTER W | ||
+ | 0x0037: 0x0058, # LATIN CAPITAL LETTER X | ||
+ | 0x0038: 0x0059, # LATIN CAPITAL LETTER Y | ||
+ | 0x0029: 0x005A, # LATIN CAPITAL LETTER Z | ||
+ | }) | ||
+ | ### Encoding Map | ||
+ | |||
+ | encoding_map = codecs.make_encoding_map(decoding_map) | ||
+ | |||
+ | </pre> | ||
=== run miniterm === | === run miniterm === | ||
Line 80: | Line 428: | ||
** <pre>sudo python -m serial.tools.miniterm --echo --encoding hexlify</pre> | ** <pre>sudo python -m serial.tools.miniterm --echo --encoding hexlify</pre> | ||
* terminal[3] | * terminal[3] | ||
− | ** <pre>sudo python -m serial.tools.miniterm --encoding iso-paper</pre> | + | ** <pre>sudo python -m serial.tools.miniterm --echo --eol LF --encoding iso-paper</pre> |
+ | * terminal[4] | ||
+ | ** <pre>sudo python -m serial.tools.miniterm --echo --eol LF --encoding eia-paper</pre> | ||
== windows == | == windows == |
Latest revision as of 16:11, 17 September 2019
Contents
trivia
- old NC-maschines might use EIA or ISO 'paper-tape' encoding on serial-communication
links
- https://www.grecosystems.com/wp-content/uploads/2015/04/CNCMinifileOM.pdf (appendix 'F', page 61-62)
- https://i-logic.com/serial/punchholes.htm
- https://i-logic.com/serial/eia.htm
- https://books.google.de/books?id=4bJJbIaOgcYC&lpg=PA12&ots=pwQCwkgdWm&dq=iso%20eia%20paper%20tape%20cnc&hl=de&pg=PA16#v=onepage&q=iso%20eia%20paper%20tape%20cnc&f=false
conversion charts
char | EIA | ASCII | ISO | remark | ||||
---|---|---|---|---|---|---|---|---|
(hex) | (dec) | (hex) | (dec) | (hex) | (dec) | |||
BS | 2A | 42 | 08 | 8 | 88 | 136 | BACKSPACE | |
HT | 33 | 51 | 09 | 9 | 09 | 9 | HORIZONTAL TABULATION | |
LF | 80 | 128 | 0A | 10 | 0A | 10 | LINE FEED | EOB |
CR | 0D | 13 | 8D | 141 | CARRIAGE RETURN | |||
10 | 16 | 20 | 32 | A0 | 160 | SPACE | ||
$ | 24 | 36 | 24 | 36 | DOLLAR SIGN | |||
% | 5B | 91 | 25 | 37 | A5 | 165 | PERCENT SIGN | EOR – Rewind Stop in ASCII |
& | 0E | 14 | 26 | 38 | A6 | 166 | AMPERSAND | |
( | 1A | 26 | 28 | 40 | 28 | 40 | LEFT PARENTHESIS | |
) | 4A | 74 | 29 | 41 | A9 | 169 | RIGHT PARENTHESIS | |
+ | 70 | 112 | 2B | 43 | 2B | 43 | PLUS SIGN | |
, | 3B | 59 | 2C | 44 | COMMA | |||
- | 40 | 64 | 2D | 45 | 2D | 45 | HYPHEN-MINUS | |
. | 6B | 107 | 2E | 46 | 2E | 46 | FULL STOP | |
/ | 31 | 49 | 2F | 47 | AF | 175 | SOLIDUS | |
0 | 20 | 32 | 30 | 48 | 30 | 48 | DIGIT ZERO | |
1 | 01 | 1 | 31 | 49 | B1 | 177 | DIGIT ONE | |
2 | 02 | 2 | 32 | 50 | B2 | 178 | DIGIT TWO | |
3 | 13 | 19 | 33 | 51 | 33 | 51 | DIGIT THREE | |
4 | 04 | 4 | 34 | 52 | B4 | 180 | DIGIT FOUR | |
5 | 15 | 21 | 35 | 53 | 35 | 53 | DIGIT FIVE | |
6 | 16 | 22 | 36 | 54 | 36 | 54 | DIGIT SIX | |
7 | 07 | 7 | 37 | 55 | B7 | 183 | DIGIT SEVEN | |
8 | 08 | 8 | 38 | 56 | B8 | 184 | DIGIT EIGHT | |
9 | 19 | 25 | 39 | 57 | 39 | 57 | DIGIT NINE | |
: | 3A | 58 | 3A | 58 | COLON | |||
= | 3D | 61 | BD | 189 | EQUALS SIGN | |||
@ | 40 | 64 | C0 | 192 | COMMERCIAL AT | |||
A | 61 | 97 | 41 | 65 | 41 | 65 | LATIN CAPITAL LETTER A | |
B | 62 | 98 | 42 | 66 | 42 | 66 | LATIN CAPITAL LETTER B | |
C | 73 | 115 | 43 | 67 | C3 | 195 | LATIN CAPITAL LETTER C | |
D | 64 | 100 | 44 | 68 | 44 | 68 | LATIN CAPITAL LETTER D | |
E | 75 | 117 | 45 | 69 | C5 | 197 | LATIN CAPITAL LETTER E | |
F | 76 | 118 | 46 | 70 | C6 | 198 | LATIN CAPITAL LETTER F | |
G | 67 | 103 | 47 | 71 | 47 | 71 | LATIN CAPITAL LETTER G | |
H | 68 | 104 | 48 | 72 | 48 | 72 | LATIN CAPITAL LETTER H | |
I | 79 | 121 | 49 | 73 | C9 | 201 | LATIN CAPITAL LETTER I | |
J | 51 | 81 | 4A | 74 | CA | 202 | LATIN CAPITAL LETTER J | |
K | 52 | 82 | 4B | 75 | 4B | 75 | LATIN CAPITAL LETTER K | |
L | 43 | 67 | 4C | 76 | CC | 204 | LATIN CAPITAL LETTER L | |
M | 54 | 84 | 4D | 77 | 4D | 77 | LATIN CAPITAL LETTER M | |
N | 45 | 69 | 4E | 78 | 4E | 78 | LATIN CAPITAL LETTER N | |
O | 46 | 70 | 4F | 79 | CF | 207 | LATIN CAPITAL LETTER O | |
P | 57 | 87 | 50 | 80 | 50 | 80 | LATIN CAPITAL LETTER P | |
Q | 58 | 88 | 51 | 81 | D1 | 209 | LATIN CAPITAL LETTER Q | |
R | 49 | 73 | 52 | 82 | D2 | 210 | LATIN CAPITAL LETTER R | |
S | 32 | 50 | 53 | 83 | 53 | 83 | LATIN CAPITAL LETTER S | |
T | 23 | 35 | 54 | 84 | D4 | 212 | LATIN CAPITAL LETTER T | |
U | 34 | 52 | 55 | 85 | 55 | 85 | LATIN CAPITAL LETTER U | |
V | 25 | 37 | 56 | 86 | 56 | 86 | LATIN CAPITAL LETTER V | |
W | 26 | 38 | 57 | 87 | D7 | 215 | LATIN CAPITAL LETTER W | |
X | 37 | 55 | 58 | 88 | D8 | 216 | LATIN CAPITAL LETTER X | |
Y | 38 | 56 | 59 | 89 | 59 | 89 | LATIN CAPITAL LETTER Y | |
Z | 29 | 41 | 5A | 90 | 5A | 90 | LATIN CAPITAL LETTER Z |
pySerial
ubuntu
prerequisites
sudo apt-get install socat
sudo apt install python-pip
pip install pyserial
virtual null-modem
- terminal[1]
sudo socat PTY,link=/dev/ttyS10 PTY,link=/dev/ttyS11
hack encodings
sudo cp usr/lip/python2.7/encodings/hp_roman8.py usr/lip/python2.7/encodings/iso_paper.py
- edit iso_paper.py as needed ...
""" Python Character Mapping Codec 'ISO_paper tape' see https://bastelbude.grade.de/mediawiki/index.php?title=EIA-ASCII-ISO_encoding for details valid: [BACKSPACE] [HORIZONTAL TABULATION] [LINE FEED] [CARRIAGE RETURN] [SPACE] $ % & ( ) + - . / 0 1 2 3 4 5 6 7 8 9 : = @ A B C D E F G H I J K L M N O P Q R S T U V W X Y Z """#" import codecs ### Codec APIs class Codec(codecs.Codec): def encode(self,input,errors='strict'): return codecs.charmap_encode(input,errors,encoding_map) def decode(self,input,errors='strict'): return codecs.charmap_decode(input,errors,decoding_map) class IncrementalEncoder(codecs.IncrementalEncoder): def encode(self, input, final=False): return codecs.charmap_encode(input,self.errors,encoding_map)[0] class IncrementalDecoder(codecs.IncrementalDecoder): def decode(self, input, final=False): return codecs.charmap_decode(input,self.errors,decoding_map)[0] class StreamWriter(Codec,codecs.StreamWriter): pass class StreamReader(Codec,codecs.StreamReader): pass ### encodings module API def getregentry(): return codecs.CodecInfo( name='iso-paper', encode=Codec().encode, decode=Codec().decode, incrementalencoder=IncrementalEncoder, incrementaldecoder=IncrementalDecoder, streamwriter=StreamWriter, streamreader=StreamReader, ) ### Decoding Map decoding_map = codecs.make_identity_dict(range(256)) decoding_map.update({ 0x0008: None, # needs to be set for encoding_map 0x000d: None, # needs to be set for encoding_map 0x0020: None, # needs to be set for encoding_map 0x0025: None, # needs to be set for encoding_map 0x0026: None, # needs to be set for encoding_map 0x0029: None, # needs to be set for encoding_map 0x002c: None, # needs to be set for encoding_map 0x002f: None, # needs to be set for encoding_map 0x0031: None, # needs to be set for encoding_map 0x0032: None, # needs to be set for encoding_map 0x0034: None, # needs to be set for encoding_map 0x0037: None, # needs to be set for encoding_map 0x0038: None, # needs to be set for encoding_map 0x003d: None, # needs to be set for encoding_map 0x0040: None, # needs to be set for encoding_map 0x0043: None, # needs to be set for encoding_map 0x0045: None, # needs to be set for encoding_map 0x0046: None, # needs to be set for encoding_map 0x0049: None, # needs to be set for encoding_map 0x004a: None, # needs to be set for encoding_map 0x004c: None, # needs to be set for encoding_map 0x004f: None, # needs to be set for encoding_map 0x0051: None, # needs to be set for encoding_map 0x0052: None, # needs to be set for encoding_map 0x0054: None, # needs to be set for encoding_map 0x0057: None, # needs to be set for encoding_map 0x0058: None, # needs to be set for encoding_map 0x0088: 0x0008, # BACKSPACE 0x0009: 0x0009, # HORIZONTAL TABULATION 0x000A: 0x000A, # LINE FEED 0x008D: 0x000D, # CARRIAGE RETURN 0x00A0: 0x0020, # SPACE 0x0024: 0x0024, # DOLLAR SIGN 0x00A5: 0x0025, # PERCENT SIGN 0x00A6: 0x0026, # AMPERSAND 0x0028: 0x0028, # LEFT PARENTHESIS 0x00A9: 0x0029, # RIGHT PARENTHESIS 0x002B: 0x002B, # PLUS SIGN 0x002D: 0x002D, # HYPHEN-MINUS 0x002E: 0x002E, # FULL STOP 0x00AF: 0x002F, # SOLIDUS 0x0030: 0x0030, # DIGIT ZERO 0x00B1: 0x0031, # DIGIT ONE 0x00B2: 0x0032, # DIGIT TWO 0x0033: 0x0033, # DIGIT THREE 0x00B4: 0x0034, # DIGIT FOUR 0x0035: 0x0035, # DIGIT FIVE 0x0036: 0x0036, # DIGIT SIX 0x00B7: 0x0037, # DIGIT SEVEN 0x00B8: 0x0038, # DIGIT EIGHT 0x0039: 0x0039, # DIGIT NINE 0x003A: 0x003A, # COLON 0x00BD: 0x003D, # EQUALS SIGN 0x00C0: 0x0040, # COMMERCIAL AT 0x0041: 0x0041, # LATIN CAPITAL LETTER A 0x0042: 0x0042, # LATIN CAPITAL LETTER B 0x00C3: 0x0043, # LATIN CAPITAL LETTER C 0x0044: 0x0044, # LATIN CAPITAL LETTER D 0x00C5: 0x0045, # LATIN CAPITAL LETTER E 0x00C6: 0x0046, # LATIN CAPITAL LETTER F 0x0047: 0x0047, # LATIN CAPITAL LETTER G 0x0048: 0x0048, # LATIN CAPITAL LETTER H 0x00C9: 0x0049, # LATIN CAPITAL LETTER I 0x00CA: 0x004A, # LATIN CAPITAL LETTER J 0x004B: 0x004B, # LATIN CAPITAL LETTER K 0x00CC: 0x004C, # LATIN CAPITAL LETTER L 0x004D: 0x004D, # LATIN CAPITAL LETTER M 0x004E: 0x004E, # LATIN CAPITAL LETTER N 0x00CF: 0x004F, # LATIN CAPITAL LETTER O 0x0050: 0x0050, # LATIN CAPITAL LETTER P 0x00D1: 0x0051, # LATIN CAPITAL LETTER Q 0x00D2: 0x0052, # LATIN CAPITAL LETTER R 0x0053: 0x0053, # LATIN CAPITAL LETTER S 0x00D4: 0x0054, # LATIN CAPITAL LETTER T 0x0055: 0x0055, # LATIN CAPITAL LETTER U 0x0056: 0x0056, # LATIN CAPITAL LETTER V 0x00D7: 0x0057, # LATIN CAPITAL LETTER W 0x00D8: 0x0058, # LATIN CAPITAL LETTER X 0x0059: 0x0059, # LATIN CAPITAL LETTER Y 0x005A: 0x005A, # LATIN CAPITAL LETTER Z }) ### Encoding Map encoding_map = codecs.make_encoding_map(decoding_map)
sudo cp usr/lip/python2.7/encodings/hp_roman8.py usr/lip/python2.7/encodings/eia_paper.py
- edit eia_paper.py as needed ...
""" Python Character Mapping Codec 'EIA_paper tape' see https://bastelbude.grade.de/mediawiki/index.php?title=EIA-ASCII-ISO_encoding for details valid: [BACKSPACE] [HORIZONTAL TABULATION] [LINE FEED] [SPACE] % & ( ) + , - . / 0 1 2 3 4 5 6 7 8 9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z """#" import codecs ### Codec APIs class Codec(codecs.Codec): def encode(self,input,errors='strict'): return codecs.charmap_encode(input,errors,encoding_map) def decode(self,input,errors='strict'): return codecs.charmap_decode(input,errors,decoding_map) class IncrementalEncoder(codecs.IncrementalEncoder): def encode(self, input, final=False): return codecs.charmap_encode(input,self.errors,encoding_map)[0] class IncrementalDecoder(codecs.IncrementalDecoder): def decode(self, input, final=False): return codecs.charmap_decode(input,self.errors,decoding_map)[0] class StreamWriter(Codec,codecs.StreamWriter): pass class StreamReader(Codec,codecs.StreamReader): pass ### encodings module API def getregentry(): return codecs.CodecInfo( name='eia-paper', encode=Codec().encode, decode=Codec().decode, incrementalencoder=IncrementalEncoder, incrementaldecoder=IncrementalDecoder, streamwriter=StreamWriter, streamreader=StreamReader, ) ### Decoding Map decoding_map = codecs.make_identity_dict(range(256)) decoding_map.update({ 0x0009: None, # [9]needs to be set for encoding_map 0x000A: None, # [10]needs to be set for encoding_map 0x0028: None, # [40]needs to be set for encoding_map 0x002B: None, # [43]needs to be set for encoding_map 0x002C: None, # [44]needs to be set for encoding_map 0x002D: None, # [45]needs to be set for encoding_map 0x002E: None, # [46]needs to be set for encoding_map 0x002F: None, # [47]needs to be set for encoding_map 0x0030: None, # [48]needs to be set for encoding_map 0x0035: None, # [53]needs to be set for encoding_map 0x0036: None, # [54]needs to be set for encoding_map 0x0039: None, # [57]needs to be set for encoding_map 0x003A: None, # [58]needs to be set for encoding_map 0x0041: None, # [65]needs to be set for encoding_map 0x0042: None, # [66]needs to be set for encoding_map 0x0044: None, # [68]needs to be set for encoding_map 0x0047: None, # [71]needs to be set for encoding_map 0x0048: None, # [72]needs to be set for encoding_map 0x004B: None, # [75]needs to be set for encoding_map 0x004C: None, # [76]needs to be set for encoding_map 0x004D: None, # [77]needs to be set for encoding_map 0x004E: None, # [78]needs to be set for encoding_map 0x004F: None, # [79]needs to be set for encoding_map 0x0050: None, # [80]needs to be set for encoding_map 0x0053: None, # [83]needs to be set for encoding_map 0x0055: None, # [85]needs to be set for encoding_map 0x0056: None, # [86]needs to be set for encoding_map 0x0059: None, # [89]needs to be set for encoding_map 0x005A: None, # [90]needs to be set for encoding_map 0x002A: 0x0008, # BACKSPACE 0x0033: 0x0009, # HORIZONTAL TABULATION 0x0080: 0x000A, # LINE FEED (EOB) 0x0010: 0x0020, # SPACE 0x005B: 0x0025, # PERCENT SIGN 0x000E: 0x0026, # AMPERSAND 0x001A: 0x0028, # LEFT PARENTHESIS 0x004A: 0x0029, # RIGHT PARENTHESIS 0x0070: 0x002B, # PLUS SIGN 0x003B: 0x002C, # COMMA 0x0040: 0x002D, # HYPHEN-MINUS 0x006B: 0x002E, # FULL STOP 0x0031: 0x002F, # SOLIDUS 0x0020: 0x0030, # DIGIT ZERO 0x0001: 0x0031, # DIGIT ONE 0x0002: 0x0032, # DIGIT TWO 0x0013: 0x0033, # DIGIT THREE 0x0004: 0x0034, # DIGIT FOUR 0x0015: 0x0035, # DIGIT FIVE 0x0016: 0x0036, # DIGIT SIX 0x0007: 0x0037, # DIGIT SEVEN 0x0008: 0x0038, # DIGIT EIGHT 0x0019: 0x0039, # DIGIT NINE 0x0061: 0x0041, # LATIN CAPITAL LETTER A 0x0062: 0x0042, # LATIN CAPITAL LETTER B 0x0073: 0x0043, # LATIN CAPITAL LETTER C 0x0064: 0x0044, # LATIN CAPITAL LETTER D 0x0075: 0x0045, # LATIN CAPITAL LETTER E 0x0076: 0x0046, # LATIN CAPITAL LETTER F 0x0067: 0x0047, # LATIN CAPITAL LETTER G 0x0068: 0x0048, # LATIN CAPITAL LETTER H 0x0079: 0x0049, # LATIN CAPITAL LETTER I 0x0051: 0x004A, # LATIN CAPITAL LETTER J 0x0052: 0x004B, # LATIN CAPITAL LETTER K 0x0043: 0x004C, # LATIN CAPITAL LETTER L 0x0054: 0x004D, # LATIN CAPITAL LETTER M 0x0045: 0x004E, # LATIN CAPITAL LETTER N 0x0046: 0x004F, # LATIN CAPITAL LETTER O 0x0057: 0x0050, # LATIN CAPITAL LETTER P 0x0058: 0x0051, # LATIN CAPITAL LETTER Q 0x0049: 0x0052, # LATIN CAPITAL LETTER R 0x0032: 0x0053, # LATIN CAPITAL LETTER S 0x0023: 0x0054, # LATIN CAPITAL LETTER T 0x0034: 0x0055, # LATIN CAPITAL LETTER U 0x0025: 0x0056, # LATIN CAPITAL LETTER V 0x0026: 0x0057, # LATIN CAPITAL LETTER W 0x0037: 0x0058, # LATIN CAPITAL LETTER X 0x0038: 0x0059, # LATIN CAPITAL LETTER Y 0x0029: 0x005A, # LATIN CAPITAL LETTER Z }) ### Encoding Map encoding_map = codecs.make_encoding_map(decoding_map)
run miniterm
- terminal[2]
sudo python -m serial.tools.miniterm --echo --encoding hexlify
- terminal[3]
sudo python -m serial.tools.miniterm --echo --eol LF --encoding iso-paper
- terminal[4]
sudo python -m serial.tools.miniterm --echo --eol LF --encoding eia-paper
windows
prerequisites
- ...
virtual null-modem
- e.g. https://www.virtual-serial-port.org/de/articles/top-6-virtual-com-port-apps/#2
- install, set up and run in demo-mode
reference
- https://i-logic.com/dncserver/
- install, set up and run in demo-mode
hack encodings
- ...
run miniterm
- ...