You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
1.1 KiB
Python
34 lines
1.1 KiB
Python
2 years ago
|
import sys
|
||
|
sys.path.append('../')
|
||
|
sys.path.append('../../')
|
||
|
sys.path.append('../../../')
|
||
|
from protocol.Celery.MBRTUSlave import app
|
||
|
|
||
|
|
||
|
|
||
|
def afterRecv(args):
|
||
|
request16 = ' '.join(hex(x) for x in args[-1])
|
||
|
request10 = ' '.join(str(int(x, 16)) for x in request16.split(' '))
|
||
|
app.backend.client.rpush("16R", request16)
|
||
|
app.backend.client.rpush("10R", request10)
|
||
|
if app.backend.client.llen('16R') == 81:
|
||
|
app.backend.client.lpop('16R')
|
||
|
if app.backend.client.llen('10R') == 81:
|
||
|
app.backend.client.lpop('10R')
|
||
|
|
||
|
|
||
|
# print(request16)
|
||
|
# print(request10)
|
||
|
|
||
|
def afterSend(args):
|
||
|
request16 = ' '.join(hex(x) for x in args[-1])
|
||
|
request10 = ' '.join(str(int(x, 16)) for x in request16.split(' '))
|
||
|
app.backend.client.rpush("16S", request16)
|
||
|
app.backend.client.rpush("10S", request10)
|
||
|
if app.backend.client.llen('16S') == 81:
|
||
|
app.backend.client.ltrim('16S', 1, -1)
|
||
|
if app.backend.client.llen('10S') == 81:
|
||
|
app.backend.client.ltrim('10S', 1, -1)
|
||
|
# request10 = ' '.join(str(int(x, 16)) for x in request16.split(' '))
|
||
|
# print(request16)
|
||
|
# print(request10)
|