Ejemplo n.º 1
0
 def test_datetimeToIridium_era0(self):
     im = IridiumModem("/port/does/not/exist")
     dt = datetime.datetime(2006,
                            6,
                            30,
                            21,
                            38,
                            36,
                            80000,
                            tzinfo=datetime.timezone.utc)
     it = im.datetimeToIridium(dt)
     self.assertEqual(it, int('0xd2ae1b4c', 16))
Ejemplo n.º 2
0
 def test_datetimeToIridium_era1(self):
     im = IridiumModem("/port/does/not/exist")
     dt = datetime.datetime(2010,
                            6,
                            30,
                            21,
                            38,
                            36,
                            120000,
                            tzinfo=datetime.timezone.utc)
     it = im.datetimeToIridium(dt)
     self.assertEqual(it, int('0x454779E8', 16))
Ejemplo n.º 3
0
 def test_datetimeToIridium_basic(self):
     im = IridiumModem("/port/does/not/exist")
     dt = datetime.datetime(2016,
                            6,
                            30,
                            21,
                            38,
                            36,
                            10000,
                            tzinfo=datetime.timezone.utc)
     it = im.datetimeToIridium(dt)
     self.assertEqual(it, int('0x2cb4d9fd', 16))
Ejemplo n.º 4
0
 def test_datetimeToIridiumText(self):
     im = IridiumModem("/port/does/not/exist")
     dt = datetime.datetime(2006,
                            6,
                            30,
                            21,
                            38,
                            36,
                            80000,
                            tzinfo=datetime.timezone.utc)
     it = im.datetimeToIridium(dt)
     itHex = "%0.8x" % it
     self.assertEqual(itHex, 'd2ae1b4c')
Ejemplo n.º 5
0
 def test_iridiumToDatetime_era1(self):
     im = IridiumModem("/port/does/not/exist")
     dt = im.iridiumToDatetime('12345678', iridiumEra=1)
     self.assertEqual(
         dt,
         datetime.datetime(2008,
                           1,
                           20,
                           7,
                           20,
                           11,
                           640000,
                           tzinfo=datetime.timezone.utc))
Ejemplo n.º 6
0
 def test_iridiumToDatetime_era0(self):
     im = IridiumModem("/port/does/not/exist")
     dt = im.iridiumToDatetime('12345678', iridiumEra=0)
     self.assertEqual(
         dt,
         datetime.datetime(1997,
                           4,
                           15,
                           3,
                           30,
                           1,
                           640000,
                           tzinfo=datetime.timezone.utc))
Ejemplo n.º 7
0
 def test_iridiumToDatetime_rounding(self):
     """ Basic test for the iridiumToDatetime method """
     im = IridiumModem("/port/does/not/exist")
     dt = im.iridiumToDatetime('2c799555')
     self.assertIsInstance(dt, datetime.datetime)
     self.assertEqual(
         dt,
         datetime.datetime(2016,
                           6,
                           26,
                           20,
                           32,
                           18,
                           10000,
                           tzinfo=datetime.timezone.utc))
Ejemplo n.º 8
0
 def test_iridiumToDatetime_basic(self):
     """ Basic test for the iridiumToDatetime method """
     im = IridiumModem("/port/does/not/exist")
     dt = im.iridiumToDatetime('2c781713')
     self.assertIsInstance(dt, datetime.datetime)
     self.assertEqual(
         dt,
         datetime.datetime(2016,
                           6,
                           26,
                           18,
                           5,
                           30,
                           790000,
                           tzinfo=datetime.timezone.utc))
Ejemplo n.º 9
0
 def test_iridiumToDatetime_moreValues(self):
     """ Various value tests for the iridiumToDatetime method """
     im = IridiumModem("/port/does/not/exist")
     dt = im.iridiumToDatetime('2c781714')
     self.assertEqual(
         dt,
         datetime.datetime(2016,
                           6,
                           26,
                           18,
                           5,
                           30,
                           880000,
                           tzinfo=datetime.timezone.utc))
     dt = im.iridiumToDatetime('2c781712')
     self.assertEqual(
         dt,
         datetime.datetime(2016,
                           6,
                           26,
                           18,
                           5,
                           30,
                           700000,
                           tzinfo=datetime.timezone.utc))
     dt = im.iridiumToDatetime('2c781702')
     self.assertEqual(
         dt,
         datetime.datetime(2016,
                           6,
                           26,
                           18,
                           5,
                           29,
                           260000,
                           tzinfo=datetime.timezone.utc))
     dt = im.iridiumToDatetime('153456df')
     self.assertEqual(
         dt,
         datetime.datetime(2015,
                           5,
                           17,
                           4,
                           11,
                           23,
                           230000,
                           tzinfo=datetime.timezone.utc))
     dt = im.iridiumToDatetime('2cb48ae1')
     self.assertEqual(
         dt,
         datetime.datetime(2016,
                           6,
                           30,
                           21,
                           8,
                           13,
                           330000,
                           tzinfo=datetime.timezone.utc))
Ejemplo n.º 10
0
import serial
import sys
import time
import logging
import threading
import re
import argparse

sys.path.append('..')

from iridiummodem.modem import IridiumModem

if __name__ == '__main__':
    logging.basicConfig(format='%(levelname)s: %(message)s',
                        level=logging.DEBUG)
    modem = IridiumModem('/dev/ttyUSB0', 19200)
    #modem = IridiumModem('/dev/ttyACM0', 38400)
    modem.connect()
    try:
        print('modem.imei ' + format(modem.imei))
        sys.stdout.flush()
        print('modem.networkName ' + format(modem.networkName))
        sys.stdout.flush()
    except:
        pass
    try:
        print('modem.geoLocation ' + format(modem.geoLocation))
        sys.stdout.flush()
    except:
        pass
Ejemplo n.º 11
0
import logging
import threading
import re
import argparse

sys.path.append('..')

from iridiummodem.modem import IridiumModem

if __name__ == '__main__':
    parser = argparse.ArgumentParser(description='Start a voice call')
    parser.add_argument('--dev',
                        dest='dev',
                        default='/dev/ttyUSB0',
                        help='serial device name (default: %(default)s)')
    parser.add_argument('number', help='destination number to dial')

    args = parser.parse_args()

    logging.basicConfig(format='%(levelname)s: %(message)s',
                        level=logging.DEBUG)
    modem = IridiumModem(args.dev, 19200)
    modem.connect()

    print('modem.model ' + format(modem.model))
    sys.stdout.flush()

    outgoingCall = modem.dial(args.number, timeout=60)
    print('outgoingCall ' + format(outgoingCall))
    sys.stdout.flush()
Ejemplo n.º 12
0
import logging
import threading
import re
import argparse

sys.path.append('..')

from iridiummodem.modem import IridiumModem

if __name__ == '__main__':
    parser = argparse.ArgumentParser(description='Send a text message')
    parser.add_argument('--dev', dest='dev', default='/dev/ttyUSB0',
                        help='serial device name (default: %(default)s)')
    parser.add_argument('number',  help='destination number for message')
    parser.add_argument('message', help='message to send')
    
    args = parser.parse_args()

    logging.basicConfig(format='%(levelname)s: %(message)s', level=logging.DEBUG)
    modem = IridiumModem(args.dev, 19200)
    modem.connect()

    print('modem.model '+format(modem.model))
    sys.stdout.flush()
    # Takes around 9 seconds to complete for a 9522A; network delivery takes another second
    sentSms = modem.sendSms(args.number, args.message, waitForDeliveryReport=False)
    # sentSms.status is always 0
    print('sentSms.status '+format(sentSms.status))
    sys.stdout.flush()
        
Ejemplo n.º 13
0
def main():
    args = parseArgsPy26() if sys.version_info[0] == 2 and sys.version_info[1] < 7 else parseArgs()
    print ('args:',args)
    modem = IridiumModem(args.port, args.baud)    
    
    print('Connecting to GSM modem on {0}...'.format(args.port))
    try:
        modem.connect(args.pin)
    except PinRequiredError:
        sys.stderr.write('Error: SIM card PIN required. Please specify a PIN with the -p argument.\n')
        sys.exit(1)
    except IncorrectPinError:
        sys.stderr.write('Error: Incorrect SIM card PIN entered.\n')
        sys.exit(1)

    if args.debug:
        # Print debug info
        print('\n== MODEM DEBUG INFORMATION ==\n')
        print('ATI', modem.write('ATI', parseError=False))
        print('AT+CGMI:', modem.write('AT+CGMI', parseError=False))
        print('AT+CGMM:', modem.write('AT+CGMM', parseError=False))
        print('AT+CGMR:', modem.write('AT+CGMR', parseError=False))
        print('AT+CFUN=?:', modem.write('AT+CFUN=?', parseError=False))
        print('AT+WIND=?:', modem.write('AT+WIND=?', parseError=False))
        print('AT+WIND?:', modem.write('AT+WIND?', parseError=False))
        print('AT+CPMS=?:', modem.write('AT+CPMS=?', parseError=False))
        print('AT+CNMI=?:', modem.write('AT+CNMI=?', parseError=False))
        print('AT+CVHU=?:', modem.write('AT+CVHU=?', parseError=False))
        print('AT+CSMP?:', modem.write('AT+CSMP?', parseError=False))
        print('AT+GCAP:', modem.write('AT+GCAP', parseError=False))
        print('AT+CPIN?', modem.write('AT+CPIN?', parseError=False))
        print('AT+CLAC:', modem.write('AT+CLAC', parseError=False))
        print()
    else:
        # Print basic info
        print('\n== MODEM INFORMATION ==\n')
        print('Manufacturer:', modem.manufacturer)
        print('Model:', modem.model)
        print('Revision:', modem.revision if modem.revision != None else 'N/A')
        print('\nIMEI:', modem.imei if modem.imei != None else 'N/A')
        print('IMSI:', modem.imsi if modem.imsi != None else 'N/A')
        print('\nNetwork:', modem.networkName)
        print('Signal strength:', modem.signalStrength)
        print()
Ejemplo n.º 14
0
import re
import argparse

from datetime import datetime
import dateutil.parser

sys.path.append('..')

from iridiummodem.modem import IridiumModem

if __name__ == '__main__':
    parser = argparse.ArgumentParser(description='Start a voice call')
    parser.add_argument('--dev',
                        dest='dev',
                        default='/dev/ttyACM0',
                        help='serial device name (default: %(default)s)')

    args = parser.parse_args()

    logging.basicConfig(format='%(levelname)s: %(message)s',
                        level=logging.DEBUG)
    modem = IridiumModem(args.dev, 19200)
    modem.connect()

    print('modem.model ' + format(modem.model))
    sys.stdout.flush()

    (lat, lon) = modem.gpsLocation

    print('lat ' + format(lat) + ' lon ' + format(lon))
Ejemplo n.º 15
0
from iridiummodem.modem import IridiumModem, SBDBinaryMessage

if __name__ == '__main__':
    parser = argparse.ArgumentParser(description='Send an SBD message')
    parser.add_argument('--dev',
                        dest='dev',
                        default='/dev/ttyUSB0',
                        help='serial device name (default: %(default)s)')
    parser.add_argument('message', help='message to send')

    args = parser.parse_args()

    logging.basicConfig(format='%(levelname)s: %(message)s',
                        level=logging.DEBUG)
    modem = IridiumModem(args.dev, 19200)
    modem.timeout = 300
    modem.connect()

    try:
        print('modem.model ' + format(modem.model))
        sys.stdout.flush()
    except:
        pass
    modem.clearIsuSBDOutboundMessage
    #msgToSend = SBDBinaryMessage(data=b'hello')
    msgToSend = SBDBinaryMessage(data=b'\x07\x08\x19\x17\x17\x12\x13')
    modem.writeSBDMessageToIsu(msgToSend)
    modem.getSBDStatus
    modem.initiateOldSBDSession
    modem.initiateSBDSession
Ejemplo n.º 16
0
import serial
import sys
import time
import logging
import threading
import re
import argparse

sys.path.append('..')

from iridiummodem.modem import IridiumModem

if __name__ == '__main__':
    logging.basicConfig(format='%(levelname)s: %(message)s', level=logging.DEBUG)
    modem = IridiumModem('/dev/ttyUSB0', 19200)
    modem.connect()
    print('modem.imei '+format(modem.imei))
    sys.stdout.flush() 
    print('modem.networkName '+format(modem.networkName))
    sys.stdout.flush()
   
    #try:
    print('modem.geoLocation '+format(modem.geoLocation))
    sys.stdout.flush()
    #except:
    #    pass

    print('modem.systemTime '+format(modem.systemTime))
    sys.stdout.flush()
Ejemplo n.º 17
0
import serial
import sys
import time
import logging
import threading
import re
import argparse
from gsmmodem.modem import Sms
sys.path.append('..')

from iridiummodem.modem import IridiumModem

if __name__ == '__main__':
    logging.basicConfig(format='%(levelname)s: %(message)s', level=logging.DEBUG)
    modem = IridiumModem('/dev/ttyACM0', 38400)
    #modem = IridiumModem('/dev/ttyUSB1', 19200)
    modem.connect()
    try:
        print('modem.imei '+format(modem.imei))
        sys.stdout.flush()
        print('modem.networkName '+format(modem.networkName))
        sys.stdout.flush()
    except:
        pass
    try:
    	print('modem.geoLocation '+format(modem.geoLocation))
    	sys.stdout.flush()
    except:
        pass
Ejemplo n.º 18
0
import threading
import re
import argparse

sys.path.append('..')

from iridiummodem.modem import IridiumModem, SBDBinaryMessage

if __name__ == '__main__':
    parser = argparse.ArgumentParser(description='Send an SBD  message')
    parser.add_argument('--dev', dest='dev', default='/dev/ttyUSB0',
                        help='serial device name (default: %(default)s)')
    parser.add_argument('message', help='message to send')
    
    args = parser.parse_args()

    logging.basicConfig(format='%(levelname)s: %(message)s', level=logging.DEBUG)
    modem = IridiumModem(args.dev, 19200)
    modem.connect()

    print('modem.model '+format(modem.model))
    sys.stdout.flush()
    modem.clearIsuSBDOutboundMessage
    msgToSend = SBDBinaryMessage(data=b'hello')
    modem.writeSBDMessageToIsu(msgToSend)
    modem.getSBDStatus
    modem.clearIsuSBDInboundMessage
    modem.getSBDStatus
    modem.copySentSBDToReceived
    modem.getSBDStatus
Ejemplo n.º 19
0
import sys
import time
import logging
import threading
import re
import argparse

sys.path.append('..')

from iridiummodem.modem import IridiumModem

if __name__ == '__main__':
    parser = argparse.ArgumentParser(description='Start a voice call')
    parser.add_argument('--dev', dest='dev', default='/dev/ttyUSB0',
                        help='serial device name (default: %(default)s)')
    parser.add_argument('number',  help='destination number to dial')
    
    args = parser.parse_args()

    logging.basicConfig(format='%(levelname)s: %(message)s', level=logging.DEBUG)
    modem = IridiumModem(args.dev, 19200)
    modem.connect()

    print('modem.model '+format(modem.model))
    sys.stdout.flush()

    outgoingCall = modem.dial(args.number, timeout=60)
    print('outgoingCall '+format(outgoingCall))
    sys.stdout.flush()
        
Ejemplo n.º 20
0
    'ATI0',
    'ATI1',
    'ATI2',
    'ATI3',
    'ATI4',
    'ATI5',
    'ATI6',
    'ATI7',
}

if __name__ == '__main__':
    parser = argparse.ArgumentParser(
        description='Check command support for a modem')
    parser.add_argument('--dev',
                        dest='dev',
                        default='/dev/ttyACM0',
                        help='serial device name (default: %(default)s)')
    args = parser.parse_args()
    logging.basicConfig(format='%(levelname)s: %(message)s',
                        level=logging.DEBUG)
    modem = IridiumModem(args.dev, 19200)
    modem.connect()

    for cmd in commandList:
        try:
            response = modem.write(cmd)
            print('' + cmd + ' response ' + format(response))
            sys.stdout.flush()
        except:
            pass
Ejemplo n.º 21
0
sys.path.append('..')

from iridiummodem.modem import IridiumModem

if __name__ == '__main__':
    parser = argparse.ArgumentParser(description='Send a text message')
    parser.add_argument('--dev',
                        dest='dev',
                        default='/dev/ttyUSB0',
                        help='serial device name (default: %(default)s)')
    parser.add_argument('number', help='destination number for message')
    parser.add_argument('message', help='message to send')

    args = parser.parse_args()

    logging.basicConfig(format='%(levelname)s: %(message)s',
                        level=logging.DEBUG)
    modem = IridiumModem(args.dev, 19200)
    modem.connect()

    print('modem.model ' + format(modem.model))
    sys.stdout.flush()
    # Takes around 9 seconds to complete for a 9522A; network delivery takes another second
    # 9555A took four seconds
    sentSms = modem.sendSms(args.number,
                            args.message,
                            waitForDeliveryReport=False)
    # sentSms.status is always 0
    print('sentSms.status ' + format(sentSms.status))
    sys.stdout.flush()