-1

I'm using AT commands to send data over http, but the problem is that sometimes the program has an error and wont run again until I reboot and the GSM. Im using a crontab and also running the file as local file on boot. How could I fix the program to just begin the script again? How do I fix segmentation fault error.

  • This is not a valid program, so it's not clear what's happening. Segmentation fault means you're writing to an illegal memory address somewhere (or a library that you're calling is), but there's no way to tell where that's happening with this fragment of code. – Brick Jun 7 '19 at 15:34
  • Hello. Could you move the error message from your comment to the question, reading it all bunched up with no formatting is a little difficult. – Roger Jones Jun 7 '19 at 18:23
  • Getting better. Now we have the program but we don't know where the error occurs. – Brick Jun 7 '19 at 18:46
  • I added the error. Thanks for your help. – 00BEAR Jun 7 '19 at 18:56
  • 1
    This is not a Pi question, but a general programming question. You are asking us to debug a poorly structured python program. You should split the code into modules and debug each module – Milliways Jun 7 '19 at 23:52
1

Obviously, the interpreter is attempting to iterate result, which (in the case your program crashes) isn't iterable because it's of typeNoneType. It seems like execute() returns None in result = execute(cmd). Looking at that function, there are two possibilities:

  1. port.read(100).decode() returns None. That's unlikely the case because the function is supposed to return an iterable type. Returning None in any case is prone to crashes and bad practice.

  2. There is an exception in execute(). In this case (except) the function will not return anything (None) which I'm pretty sure is what crashes your program.

  • Where does it answer a question to Raspberry Pi? – Ingo Jun 10 '19 at 10:25
  • I think, it answers this question at least. Whether the question is on raspberry pi or not is another story. – Sim Son Jun 10 '19 at 16:00
  • But due to our policies it should be a story. – Ingo Jun 12 '19 at 7:14

Not the answer you're looking for? Browse other questions tagged or ask your own question.