Sending AT Commands from Microcontroller - c

I am in the middle of a project that is going to use a micro-controller to tell a Sierra Wireless Raven XT to send a test message to the appropriate admin when a pump fails. I have the interrupt for the pin change when the pump fails already completed. My problem is getting the modem to send the text message. I am able to send a text message when connected to the modem through putty or hyper-terminal but when I tell the micro-controller to send those same commands I get nothing.
I am using an ATmega88PA and programming in C. To send the commands over serial communication I am using USART. When I connect to the micro-controller through putty and fake a pump fail the message that is output to the terminal is the exact thing that I would need to type in to send the message myself.
Anyone have any ideas as to what might be holding me up?

Related

Sending AT commands over UART

My problem is sending AT commands over UART. I am working with STM32 IDE. I have the hardware: STM32L476 with a sensor shield together with the ESP01 Wifi module.
I got the hardware to work and can already send the first AT command over Uart to ESP01. When I try other commands AT+RST or AT+GMR I don't get any response back.
I use this code to send over UART to ESP01.
void ATsend (char out[]){
HAL_UART_Transmit(&huart4, (uint8_t *)out, strlen(out), 1000);
}
The code below works fine
ATsend("AT");
I get the response OK.
When I try this I get no response.
ATsend("AT+RST")
Any tips?
If you are sure that your UART receiver, or your DCE in RS-232 notation, supports the commands you're sending, this guide might be helpful:
https://docs.espressif.com/projects/esp-at/en/latest/esp32/faq.html#when-the-host-mcu-sends-an-at-command-to-the-esp32-device-there-is-no-response-what-is-the-reason.
The guide indicates as a possible solution also for the ESP8266 products the following: <<When the host MCU sends an AT command to the ESP32 device, there is no response. What is the reason?
A terminator (“ATrn”) must be added after an AT command when the host MCU sending AT commands to an ESP32 device. Please see Check Whether AT Works.>>
There's also this link: https://docs.espressif.com/projects/esp-at/en/latest/esp32/Get_Started/Downloading_guide.html#check-whether-at-works.
I hope these suggestions can solve your problem. At least they can indicate to you if the device is working.
There might be other causes of malfunction, but in this case I need more information to help you solve them and I suggest that you write to my company for professional support.
Yours sincerely,
V.D.

Serial Port Communication problem while using UART

I'm trying to send and receive data between a board (Dialog DA14531) and a simulation application of a temperature sensor.
I can easily send and receive data between the board and my computer, using Termite for instance.
By using Com0Com, I can receive the data sent from the sensor simulator in Termite as well.
However; I can't directly send data between this simulator and my board. I'm using Advanced Serial Port Monitor application and while the simulator states that the connection has been established, there seem to be nothing going on with this port.
Does someone have any idea about what might have caused the problem and how should I proceed for debugging?
So, I've figured out a new way to fix the issue:
Created a pair of virtual ports by using Com0COM.
Connected the simulator to one of these ports and Termite to the other one.
Connected the board to the system.
Used port forwarding in Termite to send the received data to the board.
This way, I can also monitor the data traffic between the board and the simulator.

USB CDC Communication-Device Waiting for second command from host for sending response for first command

I'm working using atmel studio 7.0, the code which i'm using is USB Communication Device Class (CDC) for ATSAMD21. My application is to read the command from the host to the device and perform the operation suggested by the host and send acknowledgement back to the host from device.
Java GUI we are writing into MCU USB,we will receive data into MCU using udi_cdc_read_buf() call and received data we are sending back to the JAVA host as a acknowledgement using udi_cdc_write_buf() .
1.Device Waiting for second Command from host for sending response for first Command.
1st Command from host---->No acknowledgement received from device to host
2nd Command from host---->Host received acknowledgement for 1st Command .
3rd Command from host----->Host received acknowledgement 2nd Command.
Here if i debug the code i can see the data "3434" in the buffer. Device send the data to host only when another data is received from the host.
CODE SNIPPET
int write_data(uint8_t *msg){
uint8_t buffer[4]="3434";
udi_cdc_write_buf(buffer,4);
return (SUCCESS);
}
--->How this is happening in USB Communication? i'm stuck with this any help will be appreciated.

C UART not working all the time

I'm having an issue connecting a serial device to an embedded device I'm writing code for.
The device I am writing has two serial ports, an incoming from my laptop, and an outgoing to an external device.
When I connect both terminals to my laptop and view the data, I get exactly the data I am expecting.
When I connect my laptop to the external device directly, I am getting exactly what I expect, and a response.
When I connect the laptop and the external device to the embedded device I am working on, the laptop sends data to it, it receives it, it passes it on to the external device. This works as expected.
However, the external device doesn't send back the response.
If I send data to the external device from the embedded device, each new message I send allows it to send the original reply.
I know the first message got through correctly because the external device whirrs to live, and I know when it is sending the response by running and logic analyser on the tx/rx comms and viewing the traffic.
I considered that the embedded device is holding the rx line and preventing its transmission, but I don't see how that possible in the code. Also if that is the case it shouldn't work when I plug both lines into my laptop.
I also considered the DTR was not set high, but checked this and it appears to be set high.
Does anyone know a reason which would prevent a device from responding?
Note: When I say Serial Ports I am referring to the UART when referring to the embedded device. All device use a DB9 connector running RS232.
Edit: Operating System on laptop is Windows 10. Embedded device is a Atmega324p.
Edit 2: Did some more testing. It appears that it sometimes work and sometimes doesn't.
I have added an image which show a almost perfect signal of the response.
The blue section is a gap in the signal that shouldn't be there.
Ended up finding a solution.
The RTS line was held via the embedded device at 1.2v, while the Pc was holding it at 5.2v.
Pulling the RTS line up to 5v fixed the issue.

Hayes AT Commands: Detect Remote Hangup?

How are you supposed to programatically detect when the remote modem on your call hangs up? I am writing a C program which interfaces with a SoftModem device /dev/ttySL0 in Ubuntu linux. I am able to configure the modem using Hayes AT commands and communicate with the remote modem. However, I haven't been able to determine how I'm supposed to detect that the other end has hung up the line.
I have the modem configured so that when the other end hangs up, the device prints NO CARRIER and switches to command mode. However, I can't use the NO CARRIER string because I can't guarantee that the modem won't receive that string while in data mode.
How do you "listen" for remote hang up?
This is a hardware signal on modems, the Carrier Detect (CD) line. You'll need to monitor it to know that the connection was lost. Basics in linux are described in this how-to, you obtain the signal state with ioctl() using the TIOCM_CAR command.
Testing for NO CARRIER as text will not suffice. This text frequently occurs on sites in the net, even on Q&A sites.
Coming from the modem, it should be enclosed in line breaks.
Besides, after you detect that text, you can try to switch to command mode with +++. If that works, your connection persists and you can reattach it and continue using it. If it doesn't (because you are already there and +++ is an invalid command), the connection has gone.

Resources