コード例 #1
0
ファイル: RX_API.py プロジェクト: teleofis/Locker
def send(cmd, type, data):
    """Отправить команду для процессора

    Args:
        cmd: Команда
        type: Операция
        data: Данные
    """
    req = pack(cmd, type, data)
    SER2.send(req)
コード例 #2
0
def send(cmd, type, data):
    """Отправить команду для процессора

    Args:
        cmd: Команда
        type: Операция
        data: Данные
    """
    req = pack(cmd, type, data)
    SER2.send(req)
コード例 #3
0
ファイル: main.py プロジェクト: darksv/garbage
def write_registers(start_reg, *data):
    SER2.send('writing: %02x %r\r\n' % (start_reg, data))

    MDM.send(
        'AT#I2CWR=%d,%d,%02x,%02x,%d\r' %
        (GPIO_SDA, GPIO_SCL, CODEC_ADDR, start_reg, len(data)), 0)
    MDM.send(''.join(hex(x)[2:].zfill(2) for x in data), 0)
    MDM.sendbyte(0x1a, 0)

    return wait_for_response()
コード例 #4
0
ファイル: main.py プロジェクト: darksv/garbage
def read_registers(start_reg, n):
    SER2.send('reading: %02x %d\r\n' % (start_reg, n))
    MDM.send(
        'AT#I2CRD=%d,%d,%02x,%02x,%d\r' %
        (GPIO_SDA, GPIO_SCL, CODEC_ADDR, start_reg, n), 0)

    data = ''
    time_max = time.time() + 10.0
    while not contains_any(data, 'OK\r', 'ERROR\r') and time.time() < time_max:
        byte = MDM.readbyte()
        if byte != -1:
            data += chr(byte)

    data = data.lstrip()
    if data.startswith('#I2CRD: '):
        return data[8:data.index('\r')]

    return None
コード例 #5
0
ファイル: MS20.py プロジェクト: JanusRC/Python
def sendNmeaCmd (inSTR1, inSTR2):

    # Method return value:
    #   -5 = Incorrect NMEA command response
    #   -4 = No NMEA Command response
    #   -3 = NMEA Command response Checksum fail
    #   -1 = Exception occurred
    #    0 = Finished w/o error
    #   >0 = NMEA Command response error value

    # inSTR1 = MS20 NMEA command
    # inSTR2 = MS20 NMEA command data

    tmpReturn = -1

    try:

        #Build NMEA command
        #Calculate NMEA checksum
        y = inSTR1 + inSTR2
        x = calcChecksum (y[1:len(y)])
        #Format NMEA sentence
        y = y + '*' + x + '\r\n'

        #Send NMEA command
        res = SER2.send(y)      

        #Evaluate NMEA command response
        res = getNextSentence(inSTR1, 2)

        print 'NMEA Command Sent: ' + y
        if not(res == 0):
            print 'NMEA Command failed!'
            print '  Return Code: ' + str(res)
            # pass return code back to calling method
            tmpReturn = res
        else:

            tmpReturn = 0

    except:
        printException("sendNmeaCmd()")
        tmpReturn = -1

    return tmpReturn
コード例 #6
0
ファイル: main.py プロジェクト: darksv/garbage
def main():
    if config_codec():
        SER2.send('Codec configured\r\n')
    else:
        SER2.send('Cannot configure the codec\r\n')

    data = ''
    while True:
        byte = MDM.readbyte()
        if byte == -1:
            time.sleep(0.1)
            continue

        data += chr(byte)
        if not '\r' in data:
            time.sleep(0.1)
            continue

        line, data = data.split('\r', 2)
        if 'RING' in line:
            SER2.send('ring!!!\r\n')
            accept_call()
        else:
            SER2.send(line + '\r\n')
コード例 #7
0
ファイル: sertest.py プロジェクト: predat0r/GSM
import SER2
SER2.send('test')
SER2.sendbyte(0x0d)
コード例 #8
0
import time
import USB0
import SER
import SER2

SER.set_speed('115200', '8N1')
SER2.set_speed('115200', '8N1')

i = 0
print('HOLA\n')
while i < 3:
    time.sleep(1)
    a = USB0.send('TEST\r\n')
    print('HOLA\n')
    b = SER.send('PAULO\n')
    c = SER2.send('BENITO\n')
    i = i + 1

SER.send('END of script\n')
SER2.send('END OF END\n')
コード例 #9
0
ファイル: main.py プロジェクト: darksv/garbage
        data += chr(byte)
        if not '\r' in data:
            time.sleep(0.1)
            continue

        line, data = data.split('\r', 2)
        if 'RING' in line:
            SER2.send('ring!!!\r\n')
            accept_call()
        else:
            SER2.send(line + '\r\n')


SER2.set_speed('9600', '8N1')
SER2.send('Starting...\r\n')
try:
    main()
except BaseException, e:
    SER2.send(repr(e))

#
# SER2.set_speed('115200', '8N1')
#
# MDM.send('AT+CMEE=2\n', 0)
# while True:
#     MDM.send('AT+COPS=?\r', 0)
#     MDM.send('AT+CSQ\r', 0)
#     MDM.send('AT+CREG?\r', 0)
#     for line in MDM.read().split('\r\n'):
#         if line and line != 'OK':
コード例 #10
0
def resetWatchdog():
    gsm.sendAT("AT#ENHRST=1,10", "OK", 5)
    SER2.send('OK\r\n')
コード例 #11
0
                for c in commands:
                    result = result + executeCommand(c)
                sms.sendSms(sms_msg.SmsMessage('0', message.getNumber(), '', result))
                if(CFG.get('SMSDELETEALL') == '0'):
                    sms.deleteSms(message.getId())
        if(CFG.get('SMSDELETEALL') == '1'):
            sms.deleteSms(message.getId())

def resetWatchdog():
    gsm.sendAT("AT#ENHRST=1,10", "OK", 5)
    SER2.send('OK\r\n')

if __name__ == "__main__":
    try:
        SER2.set_speed('9600', '8N1')
        SER2.send('OK\r\n')
        CFG.read()
        print ('Start GSM init\r')
        gsm.init()
        print ('Start SMS init\r')
        sms.init()
        print ('IO init\r')
        initInputs()
        print ('Start main loop\r')
        while(1):
            resetWatchdog()
            smsProcessing()
            ioProcessing()
    except Exception, e:
        print ('Unhandled exception, reboot...\r')
        gsm.reboot()