Print output from serial device connected on COM port using serial module

I am trying to use the following modules in p3

controlP5 (for GUI)
serial (to communicate with a device on COM port)

... the device is a GSM SIM900 module that can understand AT commands. when I create a session in PUTTY for COM port, for every AT command I type and press ENTER, I get an acknowledgement. For e.g.

AT
OK

where AT was the command I typed and OK was the acknowledgement I got.

In p3, I made a GUI that contains 2 textboxes and a button.

I also created a serial handle,

mpo = new Serial(this,Serial.list()[0],9600);

mpo is global object of class Serial

On clicking the button, the content in the textboxes is processed and if a condition is met, then some functions in serial module are called.

mpo.clear();  
mpo.write("AT\n");

... I also have this function,

void serialEvent(Serial mp){  
ins = mp.readString();  
print(ins);  
}  

where ins is a global String object. This function, I suppose, is called whenever I send commands to module and not when the module acknowledges. So, it prints AT, but doesn't print OK... Is there any way this problem can be solved?

Answers

Sign In or Register to comment.