Quectel chip QIMODE change with '+++' & 'ATO' - mobile

I am trying to implement my library to send data over tcp connection.
In official documentation from Quectel they let you select AT+QIMODE=1 also called Transparent mode where all data sent from UART is sent over tcp connection.
I am trying to check connection status before sending data so would want to change to command mode and use AT+QISTAT. I tried sending '+++' to chip but it's sending '+++' to my server, so it's not working. Any help is greatly appreciated.
Link to official documentation, please refer to page 162 section 7.2.21

Have you ensured you have the correct time delay before and after the +++ sequence?
The documentation at section 2.2.11 (page 22) states that there must be a quiet period of 0.5 seconds before and after the +++ for it to be recognised.
To prevent the "+++" escape sequence from being misinterpreted as data, it should comply to following sequence:
No characters entered for T1 time (0.5 seconds).
"+++" characters entered with no characters in between. For CSD call or PPP online mode, the interval between two "+" MUST be less than 1 second and for a transparent TCPIP connection, the interval MUST be less than 20 ms.
No characters entered for T1 time (0.5 seconds).
Switch to command mode, otherwise go to step 1.
If you still don't have any success please post some example code.

Related

Can't get RS-232 Commands to work sending from arduino

Having issues sending RS-232 Commands from Arduino Mega to ENTTEC DMXStreamer. The RS-232 API is located here enter link description here. I am trying to send 3 commands H1 (Stop Show) HA (Load Show in slot A) H0 (Start Show that is loaded). I have tried multiple things to send the data.
setup(){
Serial2.begin(9600); //default baud rate of DMXStreamer
Serial.begin(115200);
}
loop(){
Serial2.print("H1HAH0");
delay(3000);
}
I also tried
Serial2.write(0x48);
Serial2.write(0x31);
Serial2.write(0x48);
Serial2.write(0x41);
Serial2.write(0x48);
Serial2.write(0x30);
All I get in return from the DMXStreamer is '''. I don't even see those characters as possible response codes in the API. A successful send is supposed to return '!' and negative response is '?'.
This is the code I used to read the response.
String Message = "";
while(Serial2.available())
{
char inChar = Serial2.read();
Message += inChar;
}
Serial.println(Message);
I then hooked up a usb to serial converter to the DMXStreamer and used Realterm to send the data. I went to the send tab in Realterm and typed "H1HAH0" in the box and pressed the Send ASCII button. The Streamer returned positive response !!! and I got the desired result the DMX show in slot A started playing.
What am I doing wrong in sending the data. As a side note I at one point want to use the command H3101 instead of H0. The notes for the command from the API are below. I am not sure how to sent the 101 part of the command based on the notes. Any help would be greatly appreciated.
From the API
H Command
This command is used to start,stop a show and set the show to run.
H0 Command, Start Show Format H0
If no show is stored this will have no effect
H1 Command, Stop Show The command will stop the show.
Format H1
H3 Command, Start Show with loop times
Format H3x
Warning the X value is 8 bit BINARY data, not ascii.
This command will start the show and loop X times.
To run the show once X must be set to 0x00 the maximum number of loops is 100. If X is set to 101
the show will loop forever.
The bytes are commming slow on 9600 baud. You will see available() 0 between them and before they arrive. Use Serial2.readString() for test. It waits for next byte until a second.
String Message = Serial2.readString();
Serial.println(Message);
Note: this is for a test. Don't use String or readString in the final sketch. Use C strings and readBytes with length or terminator specified.

How do I introduce a Delay in Camel to prevent file locking before the files are copied in?

I am using Camel, ActiveMq, and JMS to poll a directory and process any files it finds. The problem with larger files is they start processing before being fully copied into the directory. I has assumed (yes, I know what assume gets you) that the file system would prevent it -- but that doesn't seem to be true. The examples in the Camel docs do not seem to be working. Here is my code from within the configure method of the RouteBuilder:
from("file://" + env.getProperty("integration.directory.scan.add.eng.jobslist")+"?consumer.initialDelay=100000")
.doTry()
.setProperty("servicePath").constant("/job")
.setProperty("serviceMethod").constant("POST")
.process("engImportJobsFromFileProcessor")
.doCatch(Exception.class)
.to("log:-- Add Job(s) Error -------------------------")
.choice()
.when(constant(env.getProperty("eng.mail.enabled.flag.add.jobslist.yn")).isEqualToIgnoreCase("Y"))
.setHeader("subject", constant(env.getProperty("integration.mq.topic.add.eng.jobslist.error.email.subject")))
.to("direct://email.eng")
.otherwise()
.to("log:-----------------------------------------")
.to("log:-- Email for JOBSLIST IS DISABLED")
.to("log:-----------------------------------------")
.end()
.end()
.log("Finished loading jobs from file ")
;
As you can see, I tried to set an 'initialDelay', I have also tried 'delay' and 'readLock=changed' and nothing made a difference. As soon as the file hits the directory, Camel starts processing. All I am after is a nice simple delay before the file is polled. Any ideas?
Use option readLockMinAge.
From File2 component documentation:
This option allows you to specify a minimum age a file must be before attempting to acquire the read lock. For example, use readLockMinAge=300s to require that the file is at least 5 minutes old.
For 100s delay could URI look like this:
from("file://" + env.getProperty("integration.directory.scan.add.eng.jobslist")+"?readLock=changed&readLockMinAge=100s")
Use combination of the options "readLock=changed" , "readLockCheckInterval=1000" and readLockMinAge=20s
(1000 is in milliseconds and the default value, should be changed to higher value is writes are slower i.e the file size changes after a long time, this may happen on certain filesystems, that the file size changes not very frequently while transfer is in process)
The file component documentation # http://camel.apache.org/file2.html says
for readlock=changed
changed is using file length/modification timestamp to detect whether the file is currently being copied or not. Will at least use 1 sec. to determine this, so this option cannot consume files as fast as the others, but can be more reliable as the JDK IO API cannot always determine whether a file is currently being used by another process. The option readLockCheckInterval can be used to set the check frequency.
for readLockCheckInterval=1000
Camel 2.6: Interval in milliseconds for the read-lock, if supported by the read lock. This interval is used for sleeping between attempts to acquire the read lock. For example when using the changed read lock, you can set a higher interval period to cater for slow writes. The default of 1 sec. may be too fast if the producer is very slow writing the file.
for readLockMinAge=20s
Camel 2.15: This option applies only to readLock=change. This option allows you to specify a minimum age a file must be before attempting to acquire the read lock. For example, use readLockMinAge=300s to require that the file is at least 5 minutes old. This can speedup the poll when the file is old enough as it will acquire the read lock immediately.
So in the end your endpoint should look something like
from("file://" + env.getProperty("integration.directory.scan.add.eng.jobslist")+"?consumer.initialDelay=100000&readLock=changed&readLockCheckInterval=1000&readLockMinAge=20s")
OK, turned out to be a combination of things. First off I test inside of IntelliJ and also outside for several reasons -- one is a security issue with using email within IDEA. Tomcat, outside of IntelliJ was picking up a classes folder in the webapps/ROOT directory, which was overwriting my changes to the uri options. That's what was driving me nuts. That ROOT folder had been there from a deployment error from several months ago. But it wasn't being picked up by IntelliJ even though I was using the same Tomcat instance. That's why it appear that my changes were being ignored.

python socket difference noted on shell and code in file

I'm trying to build a python client to interact with my C server. Here's the code for the client:
import socket
s = socket.socket()
s.connect(("127.0.0.1", 12209))
print "preparing to send"
s.send("2")
s.send("mmm2.com")
s.send("mypwd")
s.send("5120")
print "Sent data"
root = s.recv(256)
print root
When I run this code on the interactive shell (the GUI IDLE) of course line by line, everything runs very fine. But when i save this code in a file and try to run it, it hangs and stops responding according to windows, what's it that I'm just not doing?
If you type it line by line, the sent strings are likely received by the server one after another in separate recv() calls.
When you execute it in a script, all the send() calls run immediately after each other without delay and the server will probably receive all the data in one bulk in a single recv() call. So the server will see "2mmm2.commypwd5120", and maybe not handle that correctly. It might wait for more input from the client.
You will need some explicit separation between the values, for example newline characters, so that the server can parse the received data correctly.

Displaying terminal output of shell on client

I have 2 files Client Side & Server Side
I send a string over the socket from client to server. I have to execute this string as one does in a terminal. The output of the command is to be displayed on the client side.
Server Side Code : this loop runs on each thread created by pthread_create
while((n=recv(sock,client_message,2000,0))>0)
{
send(sock,server_out,n,0);
}
I need to run the string i recieve in client_message as a terminal command and fetch the output of the command and send it back via the server_out string buffer.
How do i go about this ?
So - you have two or three different tasks to accomplish.
The first one is to run the command line you received on the server. For that, you can start reading the system() function. It's very straightforward to use.
But then you need to get it's output. You can read about this two points in this question.
Lastly, send that data back to the server - once you have the output stream, it's just send()ing that via the socket. You can implement some mini-protocol for telling the other side how many bytes to expect, some error detection/correction if you want, etc.
Once the data arrives the client, then you can do whatever you want with it - print it on the screen, save to a file, you name it.
Read about this things, take your chances, and come back to continue asking if you need it - good luck!

HTTP Server with Redis Event Loop

I'm a newbie, and I was trying to test the code here (which uses Redis event loop)
But when i make a request to 127.0.0.1:8000, the server doesn't send the response, it hangs. Do i need to make some changes ? I just need the request to be echoed back, which the example intends to do.
Why do you think this thing is a HTTP server? It is not. It is a broken TCP echo server.
It is broken, because the write operation is not under the control of the event loop. Some bytes will be lost if the non blocking write operation cannot send all the bytes (you have no such guarantee).
Now, if you use a proper client, this program can still be demonstrated:
$ telnet 127.0.0.1 8000
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
toto
toto
titi
titi
tutu
tutu
... while the output of the program itself is:
Accepted 127.0.0.1:48645
If you want to play with event loops, I would suggest picking one among the following list. They are probably much better documented than the first random ae hack found on github ...
libevent
libev
libuv

Resources