Skip to main content
By great demand the screenshot has been changed to text
Source Link
Shrout1
  • 172
  • 1
  • 11

TL;DR:

I need to read the time off of my Hologram Nova USB cellular modem on /dev/ttyACM0 and update the system clock after the pi restarts. I'd like to do it in Python but it isn't reading the serial tty correctly.

My build

  • I'm running python 2.7.13 on Raspbian 9
  • I'm using pyserial 3.2.1-1
  • I have a Pi 3 b+
  • The modem is a USB connected U-Blox SARA-U201 (AKA Hologram Nova)

What works so far:

  • My cellular modem is sitting on /dev/ttyACM0
  • I can communicate with it using screen /dev/ttyacm0 9600
  • I can get a time stamp in the screen session by typing AT+CCLK? and hitting Enter

Here is the output from the screen session

AT+CCLK?

+CCLK: "19/05/16,21:31:47-16"

OK

What doesn't work so far:

  • I have tried to use pyserial to interrogate the tty and return the time stamp.
  • I have tried to create an expect script using screen
  • I'd prefer not to do this with an expect script when python is a lot better.
  • I'll post my source for expect if this can't be done in Python.

Python Code:

import serial import time, sys import datetime response = '' SERIAL_PORT = "/dev/ttyACM0" ser = serial.Serial(SERIAL_PORT, baudrate = 9600, timeout = 5) ser.write("AT+CCLK?\r") response = ser.readline() print response 

When using the python console the line ser.write("AT+CCLK?\r") results in a 9 being returned on the next line. response remains empty and ser.inWaiting() is equal to 0. For further clarification hereHere is a screenshot of my attempt to query the modemtext returned from the tty:

pyserial ser.readline response

root@raspberrypi:/home/pi# python Python 2.7.13 (default, Sep 26 2018, 18:42:22) [GCC 6.3.0 20170516] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import serial >>> import time, sys >>> import datetime >>> response = '' >>> SERIAL_PORT = "/dev/ttyACM0" >>> ser = serial.Serial(SERIAL_PORT, baudrate = 9600, timeout = 5) >>> ser.write("AT+CCLK?\r") 9 >>> response = ser.readline() >>> print response 

TL;DR:

I need to read the time off of my Hologram Nova USB cellular modem on /dev/ttyACM0 and update the system clock after the pi restarts. I'd like to do it in Python but it isn't reading the serial tty correctly.

My build

  • I'm running python 2.7.13 on Raspbian 9
  • I'm using pyserial 3.2.1-1
  • I have a Pi 3 b+
  • The modem is a USB connected U-Blox SARA-U201 (AKA Hologram Nova)

What works so far:

  • My cellular modem is sitting on /dev/ttyACM0
  • I can communicate with it using screen /dev/ttyacm0 9600
  • I can get a time stamp in the screen session by typing AT+CCLK? and hitting Enter

Here is the output from the screen session

AT+CCLK?

+CCLK: "19/05/16,21:31:47-16"

OK

What doesn't work so far:

  • I have tried to use pyserial to interrogate the tty and return the time stamp.
  • I have tried to create an expect script using screen
  • I'd prefer not to do this with an expect script when python is a lot better.
  • I'll post my source for expect if this can't be done in Python.

Python Code:

import serial import time, sys import datetime response = '' SERIAL_PORT = "/dev/ttyACM0" ser = serial.Serial(SERIAL_PORT, baudrate = 9600, timeout = 5) ser.write("AT+CCLK?\r") response = ser.readline() print response 

When using the python console the line ser.write("AT+CCLK?\r") results in a 9 being returned on the next line. response remains empty and ser.inWaiting() is equal to 0. For further clarification here is a screenshot of my attempt to query the modem:

pyserial ser.readline response

TL;DR:

I need to read the time off of my Hologram Nova USB cellular modem on /dev/ttyACM0 and update the system clock after the pi restarts. I'd like to do it in Python but it isn't reading the serial tty correctly.

My build

  • I'm running python 2.7.13 on Raspbian 9
  • I'm using pyserial 3.2.1-1
  • I have a Pi 3 b+
  • The modem is a USB connected U-Blox SARA-U201 (AKA Hologram Nova)

What works so far:

  • My cellular modem is sitting on /dev/ttyACM0
  • I can communicate with it using screen /dev/ttyacm0 9600
  • I can get a time stamp in the screen session by typing AT+CCLK? and hitting Enter

Here is the output from the screen session

AT+CCLK?

+CCLK: "19/05/16,21:31:47-16"

OK

What doesn't work so far:

  • I have tried to use pyserial to interrogate the tty and return the time stamp.
  • I have tried to create an expect script using screen
  • I'd prefer not to do this with an expect script when python is a lot better.
  • I'll post my source for expect if this can't be done in Python.

Python Code:

import serial import time, sys import datetime response = '' SERIAL_PORT = "/dev/ttyACM0" ser = serial.Serial(SERIAL_PORT, baudrate = 9600, timeout = 5) ser.write("AT+CCLK?\r") response = ser.readline() print response 

When using the python console the line ser.write("AT+CCLK?\r") results in a 9 being returned on the next line. response remains empty and ser.inWaiting() is equal to 0. Here is the text returned from the tty:

root@raspberrypi:/home/pi# python Python 2.7.13 (default, Sep 26 2018, 18:42:22) [GCC 6.3.0 20170516] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import serial >>> import time, sys >>> import datetime >>> response = '' >>> SERIAL_PORT = "/dev/ttyACM0" >>> ser = serial.Serial(SERIAL_PORT, baudrate = 9600, timeout = 5) >>> ser.write("AT+CCLK?\r") 9 >>> response = ser.readline() >>> print response 
Added a screenshot and changed "ser.read(30)" to"ser.readline()"
Source Link
Shrout1
  • 172
  • 1
  • 11

TL;DR:

I need to read the time off of my Hologram Nova USB cellular modem on /dev/ttyACM0 and update the system clock after the pi restarts. I'd like to do it in Python but it isn't reading the serial tty correctly.

My build

  • I'm running python 2.7.13 on Raspbian 9
  • I'm using pyserial 3.2.1-1
  • I have a Pi 3 b+
  • The modem is a USB connected U-Blox SARA-U201 (AKA Hologram Nova)

What works so far:

  • My cellular modem is sitting on /dev/ttyACM0
  • I can communicate with it using screen /dev/ttyacm0 9600
  • I can get a time stamp in the screen session by typing AT+CCLK? and hitting Enter

Here is the output from the screen session

AT+CCLK?

+CCLK: "19/05/16,21:31:47-16"

OK

What doesn't work so far:

  • I have tried to use pyserial to interrogate the tty and return the time stamp.
  • I have tried to create an expect script using screen
  • I'd prefer not to do this with an expect script when python is a lot better.
  • I'll post my source for expect if this can't be done in Python.

Python Code:

import serial import time, sys import datetime response = '' SERIAL_PORT = "/dev/ttyACM0" ser = serial.Serial(SERIAL_PORT, baudrate = 9600, timeout = 5) ser.write("AT+CCLK?\r") response = ser.readreadline(30) print response 

When using the python console the line ser.write("AT+CCLK?\r") results in a 9 being returned on the next line. response remains empty and ser.inWaiting() is equal to 0. For further clarification here is a screenshot of my attempt to query the modem:

pyserial ser.readline response

TL;DR:

I need to read the time off of my Hologram Nova USB cellular modem on /dev/ttyACM0 and update the system clock after the pi restarts. I'd like to do it in Python but it isn't reading the serial tty correctly.

My build

  • I'm running python 2.7.13 on Raspbian 9
  • I'm using pyserial 3.2.1-1
  • I have a Pi 3 b+
  • The modem is a USB connected U-Blox SARA-U201 (AKA Hologram Nova)

What works so far:

  • My cellular modem is sitting on /dev/ttyACM0
  • I can communicate with it using screen /dev/ttyacm0 9600
  • I can get a time stamp in the screen session by typing AT+CCLK? and hitting Enter

Here is the output from the screen session

AT+CCLK?

+CCLK: "19/05/16,21:31:47-16"

OK

What doesn't work so far:

  • I have tried to use pyserial to interrogate the tty and return the time stamp.
  • I have tried to create an expect script using screen
  • I'd prefer not to do this with an expect script when python is a lot better.
  • I'll post my source for expect if this can't be done in Python.

Python Code:

import serial import time, sys import datetime response = '' SERIAL_PORT = "/dev/ttyACM0" ser = serial.Serial(SERIAL_PORT, baudrate = 9600, timeout = 5) ser.write("AT+CCLK?\r") response = ser.read(30) print response 

When using the python console the line ser.write("AT+CCLK?\r") results in a 9 being returned on the next line. response remains empty and ser.inWaiting() is equal to 0.

TL;DR:

I need to read the time off of my Hologram Nova USB cellular modem on /dev/ttyACM0 and update the system clock after the pi restarts. I'd like to do it in Python but it isn't reading the serial tty correctly.

My build

  • I'm running python 2.7.13 on Raspbian 9
  • I'm using pyserial 3.2.1-1
  • I have a Pi 3 b+
  • The modem is a USB connected U-Blox SARA-U201 (AKA Hologram Nova)

What works so far:

  • My cellular modem is sitting on /dev/ttyACM0
  • I can communicate with it using screen /dev/ttyacm0 9600
  • I can get a time stamp in the screen session by typing AT+CCLK? and hitting Enter

Here is the output from the screen session

AT+CCLK?

+CCLK: "19/05/16,21:31:47-16"

OK

What doesn't work so far:

  • I have tried to use pyserial to interrogate the tty and return the time stamp.
  • I have tried to create an expect script using screen
  • I'd prefer not to do this with an expect script when python is a lot better.
  • I'll post my source for expect if this can't be done in Python.

Python Code:

import serial import time, sys import datetime response = '' SERIAL_PORT = "/dev/ttyACM0" ser = serial.Serial(SERIAL_PORT, baudrate = 9600, timeout = 5) ser.write("AT+CCLK?\r") response = ser.readline() print response 

When using the python console the line ser.write("AT+CCLK?\r") results in a 9 being returned on the next line. response remains empty and ser.inWaiting() is equal to 0. For further clarification here is a screenshot of my attempt to query the modem:

pyserial ser.readline response

Source Link
Shrout1
  • 172
  • 1
  • 11

Reading time off of a cellular modem with python 2.7 and pyserial

TL;DR:

I need to read the time off of my Hologram Nova USB cellular modem on /dev/ttyACM0 and update the system clock after the pi restarts. I'd like to do it in Python but it isn't reading the serial tty correctly.

My build

  • I'm running python 2.7.13 on Raspbian 9
  • I'm using pyserial 3.2.1-1
  • I have a Pi 3 b+
  • The modem is a USB connected U-Blox SARA-U201 (AKA Hologram Nova)

What works so far:

  • My cellular modem is sitting on /dev/ttyACM0
  • I can communicate with it using screen /dev/ttyacm0 9600
  • I can get a time stamp in the screen session by typing AT+CCLK? and hitting Enter

Here is the output from the screen session

AT+CCLK?

+CCLK: "19/05/16,21:31:47-16"

OK

What doesn't work so far:

  • I have tried to use pyserial to interrogate the tty and return the time stamp.
  • I have tried to create an expect script using screen
  • I'd prefer not to do this with an expect script when python is a lot better.
  • I'll post my source for expect if this can't be done in Python.

Python Code:

import serial import time, sys import datetime response = '' SERIAL_PORT = "/dev/ttyACM0" ser = serial.Serial(SERIAL_PORT, baudrate = 9600, timeout = 5) ser.write("AT+CCLK?\r") response = ser.read(30) print response 

When using the python console the line ser.write("AT+CCLK?\r") results in a 9 being returned on the next line. response remains empty and ser.inWaiting() is equal to 0.