Re: Gammu-smsd issues
IT Manager <[email protected]>
| Newsgroups | gmane.linux.drivers.gammu |
|---|---|
| Message-ID | <[email protected]> |
Hi, I changed the loglevel to 255 and now gammu sees new messages within a few seconds after being sent. Without this loglevel I seem to be getting the following timeout errors: Tue 2015/03/03 14:36:33 gammu-smsd[14145]: Starting phone communication... Tue 2015/03/03 15:50:10 gammu-smsd[14145]: Error getting SMS status: No response in specified timeout. Probably phone not connected. (TIMEOUT[14]) Although it does not seem to be the perfect solution, I think I will just leave the loglevel at 255 and see if it keeps working correctly or not. I have attached the gammu.log, so you can have a look if you want. Thanks for your help. Citeren gilberto dos santos alves <[email protected]>: > hi. but remember that for loglevel = 255 to see details about of what is > going on [1] > > [1] http://wammu.eu/docs/manual/smsd/config.html#debugging > > 2015-03-02 7:58 GMT-03:00 IT Manager <[email protected]>: > >> Hi Gilberto, >> >> Thanks for your quick reply. >> >> The gammu-smsd version I use is 1.33.0. >> >> There are no messages in dmesg or syslog as I am redirecting >> everything to a seperate log for gammu, the contents of that is shown >> in my first email. >> >> My hardware is real, there is no virtualization used. >> >> The on receive script is as follows: >> >> #!/usr/bin/env python >> # This script is run when an SMS is received by SMSD >> >> from __future__ import print_function >> >> import gammu # Gammu module >> import os # Operating system dependent functionality module >> import sys # System specific module >> import glob # Pathname pattern expansion module >> import csv # CSV File Reading and Writing module >> import time # Time module >> import shutil # High-level file operations module >> import logging # Logging module >> >> # Newly received SMS are saved in /var/lib/samba/gammu/inbox as a .txt file >> # This file has the senders number in the filename and it contains the text >> # of the sms. >> # >> # This script extracts the number from the filename and reads the code from >> # the file. The code is always a number of 5 digits, anything else will be >> # logged to /var/lib/samba/gammu/SixCaseSMS.log and nothing is done with >> it. >> # The number is matched to an AED case and the code to a textual >> explanation. >> # >> # The database with the link between the AED cases, the codes and the >> numbers >> # to send the message to is stored in the file >> /var/lib/samba/gammu/SixcaseDB.csv. >> # This file is created with a macro in Excel sheet >> /var/lib/samba/gammu/SixcaseDB.xlsx. >> # /var/lib/samba/gammu/ can be reached through Windows Explorer >> through \\gthq-server\gammu\. >> # >> # The txt file is moved to the /var/lib/samba/gammu/archive folder >> after processing, so it is >> # not processed twice by mistake. >> >> ########################### >> # Defining some variables # >> ########################### >> >> # The directories used in this script >> inbox = "/var/lib/samba/gammu/inbox/" >> archive = "/var/lib/samba/gammu/archive/" >> error = "/var/lib/samba/gammu/error/" >> sixcasedb = "/var/lib/samba/gammu/SixcaseDB.csv" >> logfile = "/var/lib/samba/gammu/SixCaseSMS.log" >> smsdate = time.asctime( time.localtime(time.time()) ) >> >> global eventcode >> global sixcasenumber >> global matchedline >> global smstext >> >> ########################### >> # Defining some functions # >> ########################### >> >> # A function to check if the variable is a number >> def is_number(s): >> try: >> float(s) >> return True >> except ValueError: >> return False >> >> # A cleaning up function >> def clean_up(result): >> if 'error' in result: >> # Close the SMS file >> smsfile.close() >> # Moving the SMS file to the error folder >> shutil.move(inbox + file, error) >> elif 'success' in result: >> # Close the SMS file >> smsfile.close() >> # Moving the SMS file to the archive folder >> shutil.move(inbox + file, archive) >> else: >> with open(logfile, 'a') as log: >> log.write('[%s] - Something went wrong, check \"%s\". \n' \ >> % (smsdate, file)) >> >> # A logging function >> def log_it(l): >> with open(logfile, 'a') as log: >> # Log the start of the processing >> global result >> if 'processing' in l: >> log.write('[%s] - Started processing file \"%s\". \n' \ >> % (smsdate, file)) >> # Log everything that can go wrong, clean up and exit. >> elif 'wrong number' in l: >> log.write('[%s] - SixCase number \"%s\" could not be found in >> the >> database. \ >> Stopped processing file \"%s\" and moving it to \"%s\" >> for review. \n' \ >> % (smsdate, sixcasenumber, file, error)) >> elif 'wrong code' in l: >> log.write('[%s] - SixCase event code \"%s\" could not be found >> in >> the database. \ >> Stopped processing file \"%s\" and moving it to \"%s\" >> for review. \n' \ >> % (smsdate, eventcode, file, error)) >> elif 'no match found' in l: >> log.write('[%s] - No match was found between SixCase >> number \"%s\" and event code \"%s\" in the database. \ >> Stopped processing file \"%s\" and moving it to \"%s\" for >> review. \n' \ >> % (smsdate, sixcasenumber, eventcode, file, error)) >> elif 'format text wrong' in l: >> log.write('[%s] - The received message from \"%s\" is not >> in the correct format. \ >> Stopped processing file \"%s\" and moving it to \"%s\" >> for review. \n' \ >> % (smsdate, sixcasenumber, file, error)) >> elif 'format number wrong' in l: >> log.write('[%s] - The Sixcase number \"%s\" is not in the >> correct format. \ >> Stopped processing file \"%s\" and moving it to \"%s\" >> for review. \n' \ >> % (smsdate, sixcasenumber, file, error)) >> elif 'succes' in l: >> # If no bad things happened, continue. >> log.write('[%s] - Sent the message \"%s\" created from %s >> to %s. \n' \ >> % (smsdate, smstext, file, number)) >> >> ##################### >> # The actual script # >> ##################### >> # Find and open the SMS file(s) >> os.chdir(inbox) >> for file in glob.glob("*.txt"): >> # Starting the processing >> #log_it('processing') >> smsfile = open(file, "rb") >> # Get the number from which the SMS is received >> sixcasenumber = smsfile.name[21:33] >> #print (sixcasenumber) >> if is_number(sixcasenumber): >> # Get the eventcode from the file >> # It only reads the last event code, need to improve if >> multiple event codes are received. >> eventcode = smsfile.read() >> eventcode = eventcode.split()[-1] >> # Check if the format of the SMS is correct, i.e. [15 digit >> IMEI][space][5 digit event code] >> if is_number(eventcode): >> #print (eventcode) >> # Importing the SixcaseDB file >> with open(sixcasedb, 'rb') as f: >> dbfile = csv.reader(f, delimiter = ',') >> # Check if the sixcase number and event code exist >> searchstrings = (sixcasenumber, eventcode) >> if sixcasenumber not in open(sixcasedb).read(): >> #print ('wrong number') >> log_it('wrong number') >> clean_up('error') >> continue >> elif eventcode not in open(sixcasedb).read() : >> #print ('wrong code') >> log_it('wrong code') >> clean_up('error') >> continue >> else: >> # Find the line with both the sixcase number and >> event code >> for line in dbfile: >> # Removing any empty columns from the csv file >> import >> line = filter(None, line) >> if all(s in line for s in searchstrings): >> matchedline = line >> # Create the SMS text >> smstext = 'SixCase at %s produced event >> code %s i.e. %s.' \ >> % (matchedline[1], matchedline[2], >> matchedline[3]) >> # Extracting the numbers to send the message >> to >> length = len(matchedline) >> count = 4 >> while (count < length): >> number = (matchedline[count]) >> # Write the message and number with >> the date and time to the log file. >> #print (smstext) >> log_it('succes') >> # Translating the code to text and >> creating the message >> message = {'Text': smstext, 'SMSC': >> {'Location': 1}, 'Number': number} >> # Sending the actual messages >> smsd = gammu.SMSD('/etc/gammu-smsdrc') >> smsd.InjectSMS([message]) >> # Go to the next number in the SixcaseDB >> file >> count = count + 1 >> try: >> matchedline >> except NameError: >> # If no match was found log it >> #print ('no match found') >> log_it('no match found') >> clean_up('error') >> continue >> else: >> # If the SMS is not in the expected format put that in >> the log file. >> #print ('format text wrong') >> log_it('format text wrong') >> clean_up('error') >> else: >> # If the number is not in the expected format put that in the >> log file. >> #print ('format number wrong') >> log_it('format number wrong') >> clean_up('error') >> >> # Cleaning up after succesfully processing the file >> clean_up('success') >> >> # Finished processing >> >> Thanks for your input. >> >> >> >> ------------------------------------------------------------------------------ >> Dive into the World of Parallel Programming The Go Parallel Website, >> sponsored >> by Intel and developed in partnership with Slashdot Media, is your hub for >> all >> things parallel software development, from weekly thought leadership blogs >> to >> news, videos, case studies, tutorials and more. Take a look and join the >> conversation now. http://goparallel.sourceforge.net/ >> _______________________________________________ >> Gammu-users mailing list - >> https://lists.sourceforge.net/lists/listinfo/gammu-users >> > > > > -- > gilberto dos santos alves > +55(11)9-8646-5049 > sao paulo - sp - brasil > IT Manager Global Technics BV Bargelaan 6 2333 CT Leiden The Netherlands Tel: +31 (0)71 71 00 224 E-mail: [email protected]
gammu.log
(text/plain, 979.3 KB) - not displayed