-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathenlace.py
44 lines (35 loc) · 1021 Bytes
/
enlace.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#####################################################
# Camada Física da Computação
#Carareto
#17/02/2018
# Camada de Enlace
####################################################
# Importa pacote de tempo
import time
# Interface Física
from interfaceFisica import fisica
# enlace Tx e Rx
from enlaceRx import RX
from enlaceTx import TX
class enlace(object):
def __init__(self, name):
self.fisica = fisica(name)
self.rx = RX(self.fisica)
self.tx = TX(self.fisica)
self.connected = False
def enable(self):
self.fisica.open()
self.rx.threadStart()
self.tx.threadStart()
def disable(self):
self.rx.threadKill()
self.tx.threadKill()
time.sleep(1)
self.fisica.close()
def sendData(self, data):
self.tx.sendBuffer(data)
def getData(self, size):
data = self.rx.getNData(size)
return(data, len(data))