Difference between revisions of "EIA-ASCII-ISO encoding"

From wiki.bastelbude.grade.de
Jump to: navigation, search
(conversion charts)
(run miniterm)
 
(10 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
 +
* 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 ==
 
== conversion charts ==
Line 7: Line 12:
 
{| class="wikitable sortable"
 
{| class="wikitable sortable"
 
|-
 
|-
!class="unsortable"|char
+
!char||EIA||||ASCII||||ISO||||||remark
!class="unsortable"|EIA
+
|-
!ASCII
+
!||(hex)||(dec)||(hex)||(dec)||(hex)||(dec)||||
!class="unsortable"|ISO
+
|-
!class="unsortable"|remark
+
|BS||2A||42||08||8||88||136||BACKSPACE||
 
|-
 
|-
| ||10||20||A0|| (space)
+
|HT||33||51||09||9||09||9||HORIZONTAL TABULATION||
 
|-
 
|-
| $||80||24||24|| EOB IN EIA
+
|LF||80||128||0A||10||0A||10||LINE FEED||EOB
 
|-
 
|-
| %||5B||25||A5|| EOR – Rewind Stop in ASCII
+
|CR||||||0D||13||8D||141||CARRIAGE RETURN||
 
|-
 
|-
| +||70||2B||2B||  
+
|||10||16||20||32||A0||160||SPACE||
 
|-
 
|-
| ,||3B||2C||N/A||(Comma)
+
| $||||||24||36||24||36||DOLLAR SIGN||
 
|-
 
|-
| -||40||2D||2D|| (Minus)
+
| %||5B||91||25||37||A5||165||PERCENT SIGN||EOR – Rewind Stop in ASCII
 
|-
 
|-
| .||6B||2E||2E|| (Period)
+
| &||0E||14||26||38||A6||166||AMPERSAND||
 
|-
 
|-
| /||31||2F||AF||  
+
| (||1A||26||28||40||28||40||LEFT PARENTHESIS||
 
|-
 
|-
| 0||20||30||30||  
+
| )||4A||74||29||41||A9||169||RIGHT PARENTHESIS||
 
|-
 
|-
| 1||01||31||B1||  
+
| +||70||112||2B||43||2B||43||PLUS SIGN||
 
|-
 
|-
| 2||02||32||B2||  
+
| ,||3B||59||2C||44||||||COMMA||
 
|-
 
|-
| 3||13||33||33||  
+
| -||40||64||2D||45||2D||45||HYPHEN-MINUS||
 
|-
 
|-
| 4||04||34||B4||  
+
| .||6B||107||2E||46||2E||46||FULL STOP||
 
|-
 
|-
| 5||15||35||35||  
+
| /||31||49||2F||47||AF||175||SOLIDUS||
 
|-
 
|-
| 6||16||36||36||  
+
|0||20||32||30||48||30||48||DIGIT ZERO||
 
|-
 
|-
| 7||07||37||B7||  
+
|1||01||1||31||49||B1||177||DIGIT ONE||
 
|-
 
|-
| 8||08||38||B8||  
+
|2||02||2||32||50||B2||178||DIGIT TWO||
 
|-
 
|-
| 9||19||39||39||  
+
|3||13||19||33||51||33||51||DIGIT THREE||
 
|-
 
|-
| =||0B||3D||BD||  
+
|4||04||4||34||52||B4||180||DIGIT FOUR||
 
|-
 
|-
| A||61||41||41||  
+
|5||15||21||35||53||35||53||DIGIT FIVE||
 
|-
 
|-
| B||62||42||42||  
+
|6||16||22||36||54||36||54||DIGIT SIX||
 
|-
 
|-
| C||73||43||C3||  
+
|7||07||7||37||55||B7||183||DIGIT SEVEN||
 
|-
 
|-
| D||64||44||44||  
+
|8||08||8||38||56||B8||184||DIGIT EIGHT||
 
|-
 
|-
| E||75||45||C5||  
+
|9||19||25||39||57||39||57||DIGIT NINE||
 
|-
 
|-
| F||76||46||C6||  
+
| :||||||3A||58||3A||58||COLON||
 
|-
 
|-
| G||67||47||47||  
+
| =||||||3D||61||BD||189||EQUALS SIGN||
 
|-
 
|-
| H||68||48||48||  
+
| @||||||40||64||C0||192||COMMERCIAL AT||
 
|-
 
|-
| I||79||49||C9||  
+
| A||61||97||41||65||41||65||LATIN CAPITAL LETTER A||
 
|-
 
|-
| J||51||4A||CA||  
+
| B||62||98||42||66||42||66||LATIN CAPITAL LETTER B||
 
|-
 
|-
| K||52||4B||4B||  
+
| C||73||115||43||67||C3||195||LATIN CAPITAL LETTER C||
 
|-
 
|-
| L||43||4C||CC||  
+
| D||64||100||44||68||44||68||LATIN CAPITAL LETTER D||
 
|-
 
|-
| M||54||4D||4D||  
+
| E||75||117||45||69||C5||197||LATIN CAPITAL LETTER E||
 
|-
 
|-
| N||45||4E||4E||  
+
| F||76||118||46||70||C6||198||LATIN CAPITAL LETTER F||
 
|-
 
|-
| O||46||4F||CF||  
+
| G||67||103||47||71||47||71||LATIN CAPITAL LETTER G||
 
|-
 
|-
| P||57||50||50||  
+
| H||68||104||48||72||48||72||LATIN CAPITAL LETTER H||
 
|-
 
|-
| Q||58||51||D1||  
+
| I||79||121||49||73||C9||201||LATIN CAPITAL LETTER I||
 
|-
 
|-
| R||49||52||D2||  
+
| J||51||81||4A||74||CA||202||LATIN CAPITAL LETTER J||
 
|-
 
|-
| S||32||53||53||  
+
| K||52||82||4B||75||4B||75||LATIN CAPITAL LETTER K||
 
|-
 
|-
| T||23||54||D4||  
+
| L||43||67||4C||76||CC||204||LATIN CAPITAL LETTER L||
 
|-
 
|-
| U||34||55||55||  
+
| M||54||84||4D||77||4D||77||LATIN CAPITAL LETTER M||
 
|-
 
|-
| V||25||56||56||  
+
| N||45||69||4E||78||4E||78||LATIN CAPITAL LETTER N||
 
|-
 
|-
| W||26||57||D7||  
+
| O||46||70||4F||79||CF||207||LATIN CAPITAL LETTER O||
 
|-
 
|-
| X||37||58||D8||  
+
| P||57||87||50||80||50||80||LATIN CAPITAL LETTER P||
 
|-
 
|-
| Y||38||59||59||  
+
| Q||58||88||51||81||D1||209||LATIN CAPITAL LETTER Q||
 
|-
 
|-
| Z||29||5A||5A||  
+
| R||49||73||52||82||D2||210||LATIN CAPITAL LETTER R||
 
|-
 
|-
|CR||80||0D||8D|| (Carriage Return) EOB in EIA
+
| S||32||50||53||83||53||83||LATIN CAPITAL LETTER S||
 
|-
 
|-
|LF||**||0A||0A|| (Line Feed) EOB in ASCII (ISO)
+
| T||23||35||54||84||D4||212||LATIN CAPITAL LETTER T||
 
|-
 
|-
|HT||33||09||09|| (Tab)
+
| U||34||52||55||85||55||85||LATIN CAPITAL LETTER U||
 
|-
 
|-
|BS||2A||08||88|| (Backspace)
+
| V||25||37||56||86||56||86||LATIN CAPITAL LETTER V||
 
|-
 
|-
| &||0E||26||A6||  
+
| W||26||38||57||87||D7||215||LATIN CAPITAL LETTER W||
 
|-
 
|-
| (||7C||28||28||  
+
| X||37||55||58||88||D8||216||LATIN CAPITAL LETTER X||
 
|-
 
|-
| )||71||29||A9||  
+
| Y||38||56||59||89||59||89||LATIN CAPITAL LETTER Y||
 
|-
 
|-
| :||10||3A||3A||  
+
| Z||29||41||5A||90||5A||90||LATIN CAPITAL LETTER Z||
 
|-
 
|-
| @||6D||40||C0||
 
 
|}
 
|}
 
<pre>
 
char EIA ASCII ISO note:
 
  10 20 A0 (space)
 
$ 80 24 24 EOB IN EIA
 
% 5B 25 A5 EOR – Rewind Stop in ASCII
 
+ 70 2B 2B
 
, 3B 2C N/A (Comma)
 
- 40 2D 2D (Minus)
 
. 6B 2E 2E (Period)
 
/ 31 2F AF
 
0 20 30 30
 
1 01 31 B1
 
2 02 32 B2
 
3 13 33 33
 
4 04 34 B4
 
5 15 35 35
 
6 16 36 36
 
7 07 37 B7
 
8 08 38 B8
 
9 19 30 39
 
= 0B 3D BD
 
A 61 41 41
 
B 62 42 42
 
C 73 43 C3
 
D 64 44 44
 
E 75 45 C5
 
F 76 46 C6
 
G 67 47 47
 
H 68 48 48
 
I 79 49 C9
 
J 51 4A CA
 
K 52 4B 4B
 
L 43 4C CC
 
M 54 4D 4D
 
N 45 4E 4E
 
O 46 4F CF
 
P 57 50 50
 
Q 58 51 D1
 
R 49 52 D2
 
S 32 53 53
 
T 23 54 D4
 
U 34 55 55
 
V 25 54 56
 
W 26 57 D7
 
X 37 58 D8
 
Y 38 59 59
 
Z 29 5A 5A
 
CR 80 0D 8D (Carriage Return) EOB in EIA
 
LF ** 0A 0A (Line Feed) EOB in ASCII (ISO)
 
HT 33 09 09 (Tab)
 
BS 2A 08 88 (Backspace)
 
& 0E 26 A6
 
( 7C 28 28
 
) 71 29 A9
 
: 10 3A 3A
 
@ 6D 40 C0
 
</pre>
 
  
 
= pySerial =
 
= pySerial =
Line 195: 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 200: 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

trivia

  • old NC-maschines might use EIA or ISO 'paper-tape' encoding on serial-communication

links

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

reference

hack encodings

  • ...

run miniterm

  • ...