Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
0e4033a6
Kaydet (Commit)
0e4033a6
authored
Şub 25, 1998
tarafından
Jack Jansen
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Module to use Mac serial port as a communication link
üst
0aa9782d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
74 additions
and
0 deletions
+74
-0
mactty.py
Mac/Lib/mactty.py
+74
-0
No files found.
Mac/Lib/mactty.py
0 → 100644
Dosyayı görüntüle @
0e4033a6
#
# mactty module - Use a terminal line as communications channel.
#
# Note that this module is not very complete or well-designed, but it
# will have to serve until I have time to write something better. A unix
# module with the same API is available too, contact me (jack@cwi.nl)
# if you need it.
#
# Usage:
# t = Tty(toolname)
# t.raw() Set in raw/no-echo mode
# t.baudrate(rate) Set baud rate
# t.reset() Back to normal
# t.read(len) Read up to 'len' bytes (but often reads less)
# t.readall(len) Read 'len' bytes
# t.timedread(len,tout) Read upto 'len' bytes, or until 'tout' seconds idle
# t.getmode() Get parameters as a string
# t.setmode(args) Set parameters
#
# Jack Jansen, CWI, January 1997
#
import
ctb
DEBUG
=
1
class
Tty
:
def
__init__
(
self
,
name
=
None
):
self
.
connection
=
ctb
.
CMNew
(
'Serial Tool'
,
(
10000
,
10000
,
0
,
0
,
0
,
0
))
#self.orig_data = self.connection.GetConfig()
#if name:
# self.connection.SetConfig(self.orig_data + ' Port "%s"'%name)
self
.
connection
.
Open
(
10
)
sizes
,
status
=
self
.
connection
.
Status
()
def
getmode
(
self
):
return
self
.
connection
.
GetConfig
()
def
setmode
(
self
,
mode
):
length
=
self
.
connection
.
SetConfig
(
mode
)
if
length
!=
0
and
length
!=
len
(
mode
):
raise
'SetConfig Error'
,
(
mode
[:
length
],
mode
[
length
:])
def
raw
(
self
):
pass
def
baudrate
(
self
,
rate
):
self
.
setmode
(
self
.
getmode
()
+
' baud
%
d'
%
rate
)
def
reset
(
self
):
self
.
setmode
(
self
.
orig_data
)
def
readall
(
self
,
length
):
data
=
''
while
len
(
data
)
<
length
:
data
=
data
+
self
.
read
(
length
-
len
(
data
))
return
data
def
timedread
(
self
,
length
,
timeout
):
self
.
connection
.
Idle
()
data
,
eom
=
self
.
connection
.
Read
(
length
,
ctb
.
cmData
,
timeout
*
10
)
if
DEBUG
:
print
'Timedread(
%
d,
%
d)->
%
s'
%
(
length
,
timeout
,
`data`
)
return
data
def
read
(
self
,
length
):
return
self
.
timedread
(
length
,
0x3fffffff
)
def
write
(
self
,
data
):
if
DEBUG
:
print
'Write(
%
s)'
%
`data`
while
data
:
self
.
connection
.
Idle
()
done
=
self
.
connection
.
Write
(
data
,
ctb
.
cmData
,
0x3fffffff
,
0
)
self
.
connection
.
Idle
()
data
=
data
[
done
:]
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment