Error using matlab for messaging with huawei modem

I am using Huawei E3531 model for sending message by interfacing it with matlab. But it always shows an error. Do I need to unlock my Huawei dongle?
If not, what is the actual problem? I am using the following code:
clc;
clear all;
global BytesAvail;
global A;
global B;
tx ='ATI';
tx1=char(13);
tx2=char(26);
tx3='AT+CMGS="+919526018418"';
tx4= ' This is a test msg ';
tx5='AT+CMGF=1';
s = serial('COM5');
s.baudrate=9600;
fopen(s);
s.Terminator = 'CR';
fprintf(s,'%s', tx);
fprintf(s,'%s', tx1);
BytesAvail=s.BytesAvailable;
if(BytesAvail > 0), A=fread(s,BytesAvail,'char'); end
A;
sprintf('%c', A)
%%%%%%%%%%%%%%%Send SMS%%%%%%%%%%%%
fprintf(s,'%s', tx5);
fprintf(s,'%s', tx1);
fprintf(s,'%s', tx3);
fprintf(s,'%s', tx1);
fprintf(s,'%s', tx4);
fprintf(s,'%s', tx2);
BytesAvail=s.BytesAvailable;
if(BytesAvail > 0), B=fread(s,BytesAvail,'char'); end
B;
fclose(s)
The error is this
??? Error using ==> serial.fprintf at 144
An error occurred during writing.
Error in ==> message at 20
fprintf(s,'%s', tx);
>>>

Réponses (0)

Catégories

En savoir plus sur MATLAB Support Package for Arduino Hardware dans Centre d'aide et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by