AT Command and its voice output - modem

How can I get the voice stream of the other caller? When you dial using AT command through the terminal, it signifies that it is ringing, but when the call is answered, no sound is heard.

Check out the AT command set. There are commands for turning up the volume and turning the speaker on or off, etc that you may need to set. This one is a blast from the past and takes me back! Do you hear it dial?
http://www.computerhope.com/atcom.htm

Related

Is there a MicroPython console equivalent to any()?

Is there any way to look for console input under MicroPython without pausing the program?
Within a program, I can use, for example, uart1.any() to see if there is anything in the input buffer. If not, the program can just continue.
I have a system that runs autonomously. However, I want to be able to modify parameters after the program has started using the console. The problem is, if I just use input() then the program will pause, even if I don't want to take any action.
What I need is to be able to check the "console input buffer" periodically to see if I have entered anything and, if so, process that input, otherwise to just continue.
Is this possible?
=====================================
Many thanks for the suggestion! It works, but...
What I am trying to do is to run a process which can be interrupted by keyboard input and diverted to another process. When that is finished, I return to the original process.
The initial part works well; I poll stdin and nothing happens until I hit return (for example). The program then correctly diverts to the other routine. However, when that is finished, and I return to the original thread, it immediately diverts again, even though I have not pressed any further keys.
I have tried setting 'keypress' to None after trapping it; I have tried using stdin.flush - which doesn't work! It's as though there is still something in the input buffer that I need to purge.
Any ideas?
You can poll stdin to see if data is available before attempting to read it.
from sys import stdin
from select import poll, POLLIN
poll_obj = poll()
poll_obj.register(stdin, POLLIN)
keypress = stdin.read(1) if poll_obj.poll(0) else None
print(keypress)

Can I poll my USB HID device without first sending a command

I was able to make a working HID USB stack on my "StartUSB for PIC" board for the 18F2550 microcontroller. I based it on one of the MLA libraries, which was made for the 18F45K50 (MLA 2018_11_26, hid_custom, picdem_fs_usb_k50.x), but I converted it to work with the 18F2550 (there might have been easier ways, but only learned to work with PIC about 1 month ago). On the host side, I'm using LibUsbDotNet (also here, there might be easier ways - the documentation on this library really sucks) on a Windows 10 machine.
I'm using the HID class, full speed, and all seems to work. Although, I get some random errors on the host PC (see below), but doing one close/re-open cycle on the host side when getting the error is kind of solving it. Dirty, but it works. So I kind of ignore this now.
Win32Error:Win32Error:GetOverlappedResult Ep 0x01
995:The I/O operation has been aborted because of either a thread exit or an application request.
I'm not an expert on USB (yet). But all examples I'm seeing are based on 1) you send first a command to the device and 2) then you retrieve the answer from the device. I did some performance tests, and see that this indeed shows that I can do about 500 cycles/second. I think that is correct, because each cycle, sending command and retrieving answer, each takes 1 msec.
But do I really need to send a command? Can't I just keep reading endlessly, and when the device has somthing to say, it does send the data in an IN transaction, and when not it ignores which creates a timeout on the host side. That would mean that I can poll at 1000 cycles/second? Unfortunately, I have tried it by changing my implementation on the PIC, but I get very weird results. I think I have issues with suspend mode. That brings me to another question - how can I make the device get out of suspend mode (means that not the host, but the device should be triggering this event). I have searched the MLA library for command such as "wakeup", "resume", ... but couldn't find anything.
So, to summarize, 2 questions:
Conceptual: Can I send data from device to host without being requested for it by a command from the host?
For PIC experts: How can I have a device trigger for a wakeup from suspend mode?
And indeed, the answer is Yes on the first question.
In the meantime, I found another link on the web that contains a Visual Studio C# implementation of a USB library including all the source files.
If you're interested, this is the link
This C# host implementation works as a charm. Without sending a command to the device, I get notified immediately if a button is pressed. Great!
It also proofs that my earlier device implementation based on the original MicroChip MLA, is 100% correct. I stress tested the implementation by sending a "toggle LED command" as fast as I could, and I reach 1000 commands/second. Again great!
I think that LibUsbDotNet isn't that perfect after all. As I wrote above, I get rather unstable communication (Win32Error). But with this implementation, I don't get a single error, even after running for half an hour # 1000 commands/second.
So for me, case closed.

Any suggestion on the best way to build a serial port script?

I need to configure daily dozens of devices through serial port. The config is at it follows:
Wait for boot (i.e. a specific line appears).
Enter a sequence of commands.
Do a 'print' to check everything is right.
Move to next device.
It doesn't seem complicated, and I really need to automate it. I'm not an expert programmer, but I find my ways.
What can you suggest me to get started? Where should I look on? In particular, any great API out there that would do the dirty job for me? I'm using Windows, but I could get Linux too if really needed.
The one language that I've studied is C. But I'm open to something new as long as it can be done fast.
Thank you in advance.
That looks like a task for expect:
#!/usr/bin/expect
set timeout 20
spawn "terminal-program"
expect "a specific line"
send "sequence_of_commands"
expect "prompt >"
send "print"
and put that in a bash-loop.

Motion and fswebcam running

I am using fswebcam to capture and image, when an email is received. I thought that it would be nice to have Motion running as well. I installed Motion, and that worked fine.
However, when I tried to use fswebcam to take a picture,
I received the error:
Error selecting input 0
VIDIOC_S_INPUT: Device or resource busy
then I stopped Motion, and tried it again. It worked. So, I can only have one program accessing the camera at a time.
Is there any way round this?
Use one or the other, two apps can't read the same video camera device at the same time.
Motion is capable of running a script on event detection, so if you want to do that look in the config for on_area_detected or on_movie_start
Then get it to call some kind of shell script that attaches the current photo and emails it to you.
Hope you don't get too many events, else there will be too many emails to find the important ones.
You can use the Motion HTTP Based Control. Simply call:
http://yourraspberrypi:XXXX/0/action/snapshot
using cURL or any other method that you prefer.
Where yourraspberrypi should be the IP of your Pi, and XXXX should be the port defined under 'control_port', in /etc/motion/motion.conf
Note: A symbolic link called lastsnap.jpg created in the target_dir will always point to the latest snapshot, unless snapshot_filename is exactly 'lastsnap'
You can also use the HTTP Based Control, for example, to stop/start motion detection
More info here: http://www.lavrsen.dk/foswiki/bin/view/Motion/MotionHttpAPI
It worked for me after uninstalling motion. To do so, run the following command from the terminal:
sudo apt-get remove motion

How to get NMEA from the GPS Device?

im trying to read the current position of GPS Device...using N95 from Nokia.
I read tht i will need my device to return the NMEA lines to the serialport and then i will parse/split it to get things I want but all along I dont know what to write to the serialport to make device return the NMEA ?
Like There are other commands of AT for messaging etc...Is there any specific command to send to serialport to get NMEA ???
I found this site site which seems to guide you through everything you need to do.
I am not sure how it works in the N95, but in my HTC phone you cannot send commands to the GPS device to have it behave in a certain manner. Once I am connected to the serial port that the GPS device uses I can read a stream of data coming from it, which happens to be NMEA data. There is no way that I have found to send commands to the device to tell it how to behave.
I haven't used that specific GPS device before, but for mine, I just have to open the port and I start receiving the NMEA data immediately.
I have an N82, and as far as I know it doesn't speak NMEA directly. I use a script from this page - specifically one the titled "# Turn your S60 phone with an internal GPS (eg your N95) into a Bluetooth GPS" - to get NMEA strings.
Ahh oki so I need to run some script.Oki I think i should buy a specific GPS Device for it.
Which device will do my job in cheapest manner ?
I've never worked specifically with the N95, but most GPS devices will just start spitting out NMEA as soon as they're powered up, regardless of whether or not they have a lock. I don't know how the N95 is designed, but I'll bet it probably wasn't designed to give you access to the raw NMEA data from the GPS. You'll probably need some pretty fancy trickery to get it to do that.
If you don't need to use the N95, you might find it easier to just get a GPS module and use that instead. I've always purchased mine from SparkFun. They have some good evaluation boards boards and tutorials to help you get started.
A great way of doing this in Java ME is to use JSR 179: the Location API. Your app needs to create an implementation of LocationListener, then set it on the default LocationProvider. When your listener's locationUpdated method gets called, call:
location.getExtraInfo("application/X-jsr179-location-nmea");
This will provide access to the NMEA sentences.
You can send this over a serial port by using the Java ME commports mechanism (use:
System.getProperty("microedition.commports");
as described here).
Hope this helps,
funkybro