Paul1 hat geschrieben:
Hello DIE HARD
Thank you for answer.
You are quite right, with modems. Usual it so look like, but sometime Surprise...
Into instruction for MC35i_ATC_V02.00n (page 37) I found the following text:
To set the ME to NON-CYCLIC SLEEP mode enter
When, for example, an SMS is being received and indicated by an unsolicited result code (URC), the ME wakes up to full operation.
Note that the URC used in this example will appear only, if AT+CNMI=1,1 was configured before.
I checked it. It was only gsm-modem and laptop with Hyper terminal.
I have sent 3 SMS (one by one) and on the Hyper terminal was 3 messages without additional request:
Realy it work so. The Internal memory (ME) is not so big, only for 25 sms and need delete SMS every time after reading.
My main problem is command - IF RXD THEN GOSUB "read sms" – it run nonstop cycle and "bad performs any other commands of main code". Only in case of cable disconnection I can stop the cycle.
And for my understanding, I asked you about IF RXD THEN - how it look like? May be something wrong into my code or cable?
Now I think need set to up a additional function on the gsm-modem (like total deactivation of RS232-interface) time to time.
May be have you other ideas?
' THE MAIN CODE +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
if y = 1 then goto label30
if (day = 1) and (hour = 0) and (minute = 0) then goto label1 ' one time in month
if (dow = 0) and (hour = 0) and (minute = 0) then gosub synchron ' free of charge time-synchronization
if (hour MOD 3 = 0) and (minute = 0) then gosub filter ' check-read-delete SMS
if w = ON then goto label30 ' was a problem with pump(flag YES/NO)?
if (e>Tmax) and (hour = 7) and (minute = 0) then gosub water
if (hour = 8) and (minute = 0) then e = 0
if (hour = 17) and (minute = 0) then gosub water
if j > 0 then gosub gsm ' the report request SMS(*9=05) or in case of problem with pump
if x = ON then goto label40
if (minute MOD p) > 0 then goto label40 ' if at division on 3 returns the rest, then...
' Measurement of temperatures
gosub weather ' Wind power, Sun power, Difference T and Gradient T
if q = ON then goto label40 ' was a problem with motor(flag YES/NO)?
if T_inside >= Tmax then gosub motorup ' T higher than 30C
if T_inside <= Tmin then gosub motordown ' T lower than 20C
m = T_inside ' buffer of temporary storage of internal temperature
n = T_outside ' buffer of temporary storage of external temperature
if j > 0 then gosub gsm ' in case of problem with actuator
' Interval between measurements of temperatures is p minutes (any interval p >= 2)
if (minute > 58) then y = 0
if (minute MOD (p + 1)) = 0 then x = OFF
e = max(T_inside,m)
IF RXD THEN GOSUB filter ' EVERY TIME GOSUB TO SUBPROGRAM
' Heating or Ventilation
if T_inside < Tmin then Heater = ON
if T_inside > (Tmin+2) then Heater = OFF ' Heater
if T_inside < Tmin then LED4 = ON
if T_inside > (Tmin+2) then LED4 = OFF ' Heater Indication
if T_inside > Tmax then Ventilator = ON
if T_inside < (Tmax-2) then Ventilator = OFF ' Ventilator
' Management keys: F1,F2,F3,F4
if not F1 then gosub water ' F1 - manual watering within t seconds
if not F2 then gosub up ' F2 - manual open window
if not F3 then gosub down ' F3 - manual close window
if not F4 then gosub filter ' F4 - manual check-read-delete SMS
' Accu voltage control =12V
if U12 < 110 then j = 1 ' the accu is empty
if j > 0 then gosub gsm ' the report request with SMS(*9=05) or in case of problem with equipment
' Sunlight control and ON/OFF additional light
if hour < 6 then goto label50 ' before 6 Light OFF
if hour => 19 then goto label50 ' after 19 Light OFF
if Sun > 120 then goto label50 ' the Sun power control and
if Sun < 80 then Lamp = 1 ' ON/OFF the additional Light
Lamp = 0
' The END of main code ----------------------------------------------------------------
Well, what i can tell u about IF RXD THEN ....
When the modem issues a messge, RXD will be TRUE and that
will cause this request to jump to the "read sms" subroutine.
(RXD will become TRUE if an unread byte is in the 8 byte buffer,
RXD turns false after all bytes in this buffer were read. It is a FIFO. Reading one byte shifts the buffer and makes space for one more byte to receive and buffer. Overrun the buffer will drop all bytes after buffer is full)
So far so good. The old version has 8 byte serial buffer,
what means the full message is lost.
You only can use that IF RXD THEN... as a indicator that
the modem has issued a sms reveive message, and then
flush the buffer (read until it is empty, and RXD false)
and then retrieve the message or sms with a proper read command
sent to the modem. And then immediately compute and evaluate the
modem response in a time that is fast enough to make sure that the 8 byte buffer has no overrun during evaluation of each byte
while the modem continues to send the message.
well, i hope that details are helpful in some way.