×

Discussion Board

Results 1 to 7 of 7

Thread: KerrGeneral

  1. #1
    Registered User
    Join Date
    Jan 2008
    Posts
    4

    KerrGeneral

    Our fondation is building a Public Park in Italy, i'm freely working to get images of the building going up.

    In a N73 I have a phyon script who get photos every 10 minutes in the day time and in the night time it sends the photos to a webserver (you can see a preview here www.parcoattigliano.eu), often i get an error ("Errno -2" KerrGeneral), after few days or after 6 days, no more.

    Usualy the error is after 6 days by the first shot in the day, i can't resolve the problem because i think is depending in some other problem that i can't reconaise.

    Thanks. Federico


    Code:
    ### sorry, comment and log info are in italian
    
    from graphics import *
    
    import e32
    import httplib, urllib
    import appuifw
    import camera
    import base64
    import os
    from socket import *
    from messaging import *
    from sysinfo import *
    from sys import *
    from e32db import format_time
    from time import *
    
    
    # app_lock = e32.Ao_lock()
    
    global ora_invio
    global ora_avvio
    ora_invio = 19
    ora_avvio = 6
    
    global minuti
    minuti = 10
    
    operatore = '+3939393939'
    min_drive_space = 5000000
    server = '64.22.71.126'
    drive = u'E:\\'
    min_interval = 1
    apo = access_point(2)
    serverdir = '/prova/'
    ris_oriz_test = 640
    ris_vert_test = 480
    ris_oriz = 1280
    ris_vert = 960
    
    
    #import _elocation as elocation
    #print elocation.gsm_location() # Hey ! I've already seen this function somewhere    
    #print elocation.extended_gsm_location() # NEW
    
    #import location
    #print location.gsm_location()
    
    timer = e32.Ao_timer()
    
    def log(event):
     timing = strftime('%m%d%H%M%S')
     nram = " freeram: "
     ram = str(free_ram())
     ncarica = " carica: "
     carica = str(battery())
     nevent =" event: "
     event = str(event)
     nprofile = " profile: "
     profile = str(active_profile())
     accapo = "\n"
     print " ram: " , ram , " batteria: " , carica , " profile: ", profile, " event: " , event
     testo = timing + nram + ram + ncarica + carica + nprofile + profile + nevent + event + accapo
     now = strftime('%Y%m%d')
     destinazione = "E:\\dainviare\\" + now + ".txt"
     file = open(destinazione,'a')
     file.write(testo)
     file.close()
    
    def countdown(limit): # dorme un numero di minuti
     i = limit
     while i > 0:
      i = i - 1
      timer.after(60)
    
    def dormi():  # dorme fino alla ora_avvio
     a = 1
     sms_send(operatore, u"Vado a dormire e mi sveglio alle " + str(ora_avvio))
     while a > 0:
      timer.after(900)  # dormo 15 minuti
      a = 1
      print "Dormo altri 15 minuti..."
      hour = int(strftime('%H'))
      if hour == ora_avvio :  # mi sveglio
       a = 0
       print "Sveglia..."
       sms_send(operatore, u"Mi sono svegliato bene stamattina")
    
    def leggi_par():
     try:
      print "Leggo parametri."
      conn = httplib.HTTPConnection(server)
      conn.request('GET', '/attigliano/minuti_foto')
      r1 = conn.getresponse()
      print r1.status
      minuti = int(r1.read())
      print "Intervallo in minuti: ", minuti
      conn.request('GET', '/attigliano/ora_invio')
      r1 = conn.getresponse()
      print r1.status
      ora_invio = int(r1.read())
      print "Ora di invio: ", ora_invio
      conn.request('GET', '/attigliano/ora_avvio')
      r1 = conn.getresponse()
      print r1.status
      ora_avvio = int(r1.read())
      print "Ora di avvio: ", ora_avvio
      conn.close()
     except:
      print "Errore di connessione."
      log("Errore di connessione.")
    
    # INIZIO MAIN
    
    #appuifw.app.screen = 'large'
    #appuifw.app.title = u"Attigliano"
    
    
    #ok = appuifw.query(u"Avvio il programma?", "query")
    #if not ok :
    # appuifw.app.set_exit()
    
    # creo directory     
    sourcedir = 'E:\\dainviare\\'
    if os.path.exists(sourcedir):
     print "La cartella ", sourcedir, "gia esiste."
    else:     
     os.mkdir(sourcedir)
    
    destdir = 'E:\\inviati\\'
    if os.path.exists(destdir):
     print "La cartella ", destdir, "gia esiste."
    else:
     os.mkdir(destdir)
     
    set_default_access_point(apo) 
    
    # get dei parametri
    try:
     print "Leggo parametri."
     conn = httplib.HTTPConnection(server)
     conn.request('GET', '/attigliano/minuti_foto')
     r1 = conn.getresponse()
     print r1.status
     minuti = int(r1.read())
     print "Intervallo in minuti: ", minuti
     conn.request('GET', '/attigliano/ora_invio')
     r1 = conn.getresponse()
     print r1.status
     ora_invio = int(r1.read())
     print "Ora di invio: ", ora_invio
     conn.request('GET', '/attigliano/ora_avvio')
     r1 = conn.getresponse()
     print r1.status
     ora_avvio = int(r1.read())
     print "Ora di avvio: ", ora_avvio
     conn.close()
    except:
     print "Errore di connessione."
     log("Errore di connessione.")
    
     
     
    while 1:
     # verifico se ora di partire senno vado a dormire
     hour = int(strftime('%H'))
     print "Ora adesso: ", hour, " Ora di avvio: ", ora_avvio
     if not ((ora_avvio <= hour) and (hour <= ora_invio)) :
      print "Vado a dormire!"
      dormi()
      contascatti = 0
     else :
      # imposto filename a ora corrente, scatto e salvo file in sourcedir
      dormo = "N"
      now = strftime('%Y%m%d%H%M%S')
      filename = sourcedir + "%s.jpg" % (now, )
      print filename
      event = "filename: ", filename
      log(filename)
      image = camera.take_photo(mode = ('RGB'), size = (ris_oriz, ris_vert), position = (0), flash = ('none'))
      #try:
      image.save (filename)
      contascatti = contascatti + 1
      if contascatti == 1 :
       sms_send(operatore, u"Ho fatto la prima foto di oggi")
      #except:
       #print "Errore salvataggio file: " + filename
       #log("Errore salvataggio file: " + filename)
      # se ora_invio mando le foto in sourcedir e il file di log, a meno che la batteria sia sotto il 50. In quel caso dormo.
      hour = int(strftime('%H'))
      print "Ora adesso: ", hour, " Ora di invio: ", ora_invio
      if hour == ora_invio :
       level = battery()
       if level <= 50 :
        print 'battery < 50'
        event = "sono le ", hour, ", ma batteria < 50 quindi loggo e buona notte!"
        log (event)
        dormo = "S"
       else:   # se la batt  sopra 50 invio tutto, ma solo se non sono offline.
        print "Batteria ok"
        profile = str(active_profile())
        if profile == "offline":
         event = "sono offline mentre tento upload"
         log (event)
         print "sono offline mentre tento upload"
        else:
         print "Invio!"
         sms_send(operatore, u"Inizio dell'invio odierno.")
         conta = 0
         try:
          conn = httplib.HTTPConnection(server)
         except:
          print "Errore di connessione."
          log("Errore di connessione.")
         # timer = e32.Ao_timer()
         timer.after(5)
         # per ogni file in sourcedir lo invio e lo sposto in destdir + data
         for each in os.listdir(sourcedir):
          now = strftime('%Y%m%d%')
          if not os.path.exists(destdir + now) :
           os.mkdir(destdir + now)
          if each.rfind('.jpg') != -1:
           print each
           thefile = open(sourcedir + each)
           datablock = thefile.read()
           print "uploading"
           try:
            conn.request('PUT', serverdir + each, datablock)
            response = conn.getresponse()
            if int(response.status) == 201 :
             conta = conta + 1
            print response.status, "-", response.reason, repr(response.msg.dict), response.read()
            thefile.close()
            e32.file_copy(destdir + now + '\\' + each, sourcedir + each)
            print each + ' file copied.'
            os.remove(sourcedir+each)
            print each + ' file removed.'
           except:
            print "Errore di connessione."
            log("Errore di connessione.")
          if each.rfind('.txt') != -1:
           try:
            print each
            thefile = open(sourcedir + each)
            datablock = thefile.read()
            print "uploading log file."
            conn.request('PUT', serverdir + each, datablock)
            response = conn.getresponse()
            print response.status, "-", response.reason, repr(response.msg.dict), response.read()
            thefile.close()
            e32.file_copy(destdir + now + '\\' + each, sourcedir + each)
            print each + ' file copied.'
            os.remove(sourcedir + each)
            print each + ' file removed.'
           except:
            print "Errore di connessione."
            log("Errore di connessione.")
          #except IOError: None # it prevents common errors
         
         conn.close()  #chiudo la conn leggo eventuali nuovi par e vado a dormire fino alla sveglia
         sms_send(operatore, u"Fine dell'invio odierno: inviate " + str(conta) + " foto.")
         leggi_par()
         dormo = "S"
         # se lo spazio e poco mando sms
         drive_space = free_drivespace()[u'E:']
         if drive_space < min_drive_space :
          print 'no more space'
          sms_send(operatore, u"disk space is below 5 MB")
      else:  # se non  ora di inviare aspetto un intervallo per fare altri scatti
       print "Pisolo ", minuti, " minuti."
       countdown(minuti)
      if dormo == "S":
       event = "Devo andare a dormire."
       # log (event)
       print "Devo andare a dormire."
       dormi()  # dormo fino alle 6 circa

  2. #2
    Nokia Developer Champion
    Join Date
    Feb 2008
    Location
    Ahmedabad, Gujarat, India
    Posts
    3,852

    Re: KerrGeneral

    hi fedricopalumbo
    welcome to the wonderful python dibo
    as i think u just want to take photos at regular intervals and upload it to a webserver.
    m i understood ur application correctly.
    plz reply

  3. #3
    Registered User
    Join Date
    Jan 2008
    Posts
    4

    Re: KerrGeneral

    Yes i take photos every 10 minutes, it i already working but sometimes i get an KerrGeneral -2.
    I don't know why, it work pefectelly for some days and than crash. It may be an error on symbian, afetr some days the mobile phone is on and it make some problem to the script. When i get the error the mobile phone is still working god, just the script stop. Please... every time it stop i have to reach the place (70km from my house) and to restart the phone and the script... If you want to try the script you have to change the server info...

  4. #4
    Nokia Developer Moderator
    Join Date
    May 2007
    Location
    21.46 N 72.11 E
    Posts
    3,795

    Re: KerrGeneral

    Hi federicopalumbo,

    I had such errors when I was preparing my mobilecam/security cam applications.
    I had figured out that these errors indicate that a previous process is in progress.In my case this error occurred at times when the camera was used by other application.

    I didn't go through your code, it seems very complicated on the first view, but I recommend you to clean up the code a bit and make it look little simple (keep focus on just clicking and uploading the photos) and then repost the elegant code, then we might be able to help you.

    Best Regards
    Crooozes
    Pankaj Nathani
    www.croozeus.com

  5. #5
    Registered User
    Join Date
    Jan 2008
    Posts
    4

    Re: KerrGeneral

    Here shorter and easier version.
    I translate the comment in english.

    The script take photos every 10 minutes between 6 am and 7 pm, than all the photos are sent with http PUT to a web server and the script go to sleep until 6 am of the coming day.
    With an external application the profile is switched offline/silent. I use this script to take regular picture of a building coming up, you can get more info and preview here: www.parcoattigliano.eu, the place is without electricity and i use solar panel and a car battery.
    All is already working since 17 Jennuary with thousands photos taken and sent to my webserver.
    The problem is that after 6 days (few times less days) the script stop during the first take_photo of the day and i have to reach the place (70 km far) and restart the mobile and the script. Always I found the mobile phone working fine and the script reporting SymbianError: [Errno -2] KerrGeneral.

    I think is some problem with Symbian OS.

    Other possibility is to make sis and to restart all every day, but i tried to compile without success, some one can help me?

    There's a way to autostart the script?

    Code:
    from graphics import *
    import e32
    import httplib, urllib
    import appuifw
    import camera
    import base64
    import os
    from socket import *
    from messaging import *
    from sysinfo import *
    from sys import *
    from e32db import format_time
    from time import *
    
    
    # hour to start in the morning and hour to send the photos
    global hour_put
    global hour_start
    hour_put = 19 # 7 pm
    hour_start = 6
    
    # this variabiles in for the sleeping between shots
    global minutes
    minutes = 10
    
    mymobilephone = '+3939393939'
    min_drive_space = 5000000
    server = '64.22.71.126'
    drive = u'E:\\'
    min_interval = 1
    apo = access_point(2)
    serverdir = '/prova/'
    res_oriz_test = 640
    res_vert_test = 480
    res_oriz = 1280
    res_vert = 960
    
    timer = e32.Ao_timer()
    
    
    # this function is for log
    def log(event):
     timing = strftime('%m%d%H%M%S')
     nram = " freeram: "
     ram = str(free_ram())
     ncarica = " carica: "
     carica = str(battery())
     nevent =" event: "
     event = str(event)
     nprofile = " profile: "
     profile = str(active_profile())
     accapo = "\n"
     testo = timing + nram + ram + ncarica + carica + nprofile + profile + nevent + event + accapo
     now = strftime('%Y%m%d')
     destinazione = "E:\\dainviare\\" + now + ".txt"
     file = open(destinazione,'a')
     file.write(testo)
     file.close()
    
    # this function in the sleeping cicle between take_photo
    def countdown(limit): # dorme un numero di minutes
     i = limit
     while i > 0:
      i = i - 1
      timer.after(60)
    
    # this function is to let the script sleep in the night time
    def gotosleep():  # sleep until hour_start
     a = 1
     sms_send(mymobilephone, u"I go to sleep and i wakeup at " + str(hour_start))
     while a > 0:
      timer.after(900)  # sleep 15 minute
      a = 1
      print "sleep other 15 minutes..."
      hour = int(strftime('%H'))
      if hour == hour_start :  # wakeup
       a = 0
       print "Wakeup..."
       sms_send(mymobilephone, u"I wake up perfectelly today!")
    
    
    def get_par():
     try:
      print "get variabiles from remote server."
      conn = httplib.HTTPConnection(server)
      conn.request('GET', '/prova/minutes_foto')
      r1 = conn.getresponse()
      print r1.status
      minutes = int(r1.read())
      print "waiting between shots in minutes: ", minutes
      conn.request('GET', '/prova/hour_put')
      r1 = conn.getresponse()
      print r1.status
      hour_put = int(r1.read())
      print "time to send photos: ", hour_put
      conn.request('GET', '/prova/hour_start')
      r1 = conn.getresponse()
      print r1.status
      hour_start = int(r1.read())
      print "time to start: ", hour_start
      conn.close()
     except:
      log("Error connection.")
    
    
    
    
    # creo directory     
    sourcedir = 'E:\\tosend\\'
    if os.path.exists(sourcedir):
     print "the folder ", sourcedir, "already exist."
    else:     
     os.mkdir(sourcedir)
    
    destdir = 'E:\\inviati\\'
    if os.path.exists(destdir):
     print "the folder ", destdir, "already exist."
    else:
     os.mkdir(destdir)
     
    set_default_access_point(apo) 
    
    
    
    
    
    
    # here start the big while where photos are taken
    while 1:
     # verifing if is time to start or to sleep
     hour = int(strftime('%H'))
     print "actual time: ", hour, " time to start: ", hour_start
     if not ((hour_start <= hour) and (hour <= hour_put)) :
      print "i go to sleep!"
      dormi()
      countershots = 0
     else :
      # filename and actual time, take_photo and save in sourcedir
      sleeping = "N"
      now = strftime('%Y%m%d%H%M%S')
      filename = sourcedir + "%s.jpg" % (now, )
      event = "filename: ", filename
      log(filename)
      image = camera.take_photo(mode = ('RGB'), size = (res_oriz, res_vert), position = (0), flash = ('none'))
      image.save (filename)
      countershots = countershots + 1
      if countershots == 1 :
       sms_send(mymobilephone, u"Taken first shot of today") # just to have information if all is working
      hour = int(strftime('%H'))
      print "Actual Time: ", hour, " Time for put photos: ", hour_put
      if hour == hour_put :
        print "put all the photo!"
        sms_send(mymobilephone, u"start of sending.")
        conta = 0
        try:
         conn = httplib.HTTPConnection(server)
        except:
         log("connection error")
        timer.after(5)
        # for each file in sourcedir send and move in destdir + data
        for each in os.listdir(sourcedir):
         now = strftime('%Y%m%d%')
         if not os.path.exists(destdir + now) :
          os.mkdir(destdir + now)
         if each.rfind('.jpg') != -1:
          print each
          thefile = open(sourcedir + each)
          datablock = thefile.read()
          print "uploading"
          try:
           conn.request('PUT', serverdir + each, datablock)
           response = conn.getresponse()
           if int(response.status) == 201 :
            conta = conta + 1
           print response.status, "-", response.reason, repr(response.msg.dict), response.read()
           thefile.close()
           e32.file_copy(destdir + now + '\\' + each, sourcedir + each)
           print each + ' file copied.'
           os.remove(sourcedir+each)
           print each + ' file removed.'
          except:
           print "connection error"
           log("connection error")
         if each.rfind('.txt') != -1:
          try:
           print each
           thefile = open(sourcedir + each)
           datablock = thefile.read()
           print "uploading log file."
           conn.request('PUT', serverdir + each, datablock)
           response = conn.getresponse()
           print response.status, "-", response.reason, repr(response.msg.dict), response.read()
           thefile.close()
           e32.file_copy(destdir + now + '\\' + each, sourcedir + each)
           print each + ' file copied.'
           os.remove(sourcedir + each)
           print each + ' file removed.'
          except:
           log("connection error.")
        
        conn.close()  #close the connection, get variabiles from remote server and sleep
        sms_send(mymobilephone, u"End of today put photo: snet " + str(conta) + " photos.")
        get_par() # get variabiles from remote server
        sleeping = "S"
        # i check drivespace and if < min_drive_space send sms
        drive_space = free_drivespace()[u'E:']
        if drive_space < min_drive_space :
         print 'no more space'
         sms_send(mymobilephone, u"disk space is below 5 MB")
      else:  # if is not time to sleep i white  minutes  to sleep
       print "sleep ", minutes, " minutes."
       countdown(minutes)
      if sleeping == "S":
       event = "i have to sleep."
       # log (event)
       print "i have to sleep."
       gotosleep()

  6. #6
    Nokia Developer Champion
    Join Date
    Feb 2008
    Location
    Ahmedabad, Gujarat, India
    Posts
    3,852

    Re: KerrGeneral

    Quote Originally Posted by federicopalumbo View Post
    Yes i take photos every 10 minutes, it i already working but sometimes i get an KerrGeneral -2.
    I don't know why, it work pefectelly for some days and than crash. It may be an error on symbian, afetr some days the mobile phone is on and it make some problem to the script. When i get the error the mobile phone is still working god, just the script stop. Please... every time it stop i have to reach the place (70km from my house) and to restart the phone and the script... If you want to try the script you have to change the server info...
    hi federicopalumbo
    i think the problem may be with the hardware and device specification as ur code seems to be alright. moreover i scripted the same application and my phone crashed in 15mnts.
    plz give feedback
    thanx

  7. #7
    Registered User
    Join Date
    Jan 2008
    Posts
    4

    Re: KerrGeneral

    Yes i think the problem is with Symbian, may be some application or operation is in process and we don't know and that causes the crash.
    I hope to find some who know enought Symbian and can give some help.

    Other possibility is to re-autostart everyday the OS and the script with some external application, but i didn't success in compile the script and seems there's no way to autorun the python script.

    Quote Originally Posted by gaba88 View Post
    hi federicopalumbo
    i think the problem may be with the hardware and device specification as ur code seems to be alright. moreover i scripted the same application and my phone crashed in 15mnts.
    plz give feedback
    thanx

Similar Threads

  1. CMMFDevVideoRecord::Initilize() returns with KErrGeneral
    By pncbose in forum Symbian Media (Closed)
    Replies: 0
    Last Post: 2007-04-30, 07:26
  2. RecvFrom => KErrGeneral in an endless loop
    By glr in forum Symbian Networking & Messaging (Closed)
    Replies: 3
    Last Post: 2006-08-29, 10:49
  3. KErrGeneral returned from AknIconUtils::SetSize
    By JamesLockett in forum Symbian Media (Closed)
    Replies: 0
    Last Post: 2006-06-16, 14:40
  4. Where do I find iStatus error codes?
    By arachidyl in forum Symbian Networking & Messaging (Closed)
    Replies: 7
    Last Post: 2006-03-23, 18:24

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×