Serial port stops receiving data after an hour or so

4 views (last 30 days)
Hello,
I'm running MATLAB 2015a and have assembled a program that sends and receives data from a PLC. Here's the basic set up:
% Define the serial port
kv_serial = serial(serial_port, 'Terminator', 'CR/LF', 'Parity', 'Even');
kv_serial.BytesAvailableFcnMode = 'terminator';
kv_serial.BytesAvailableFcn = {@grinder_callback};
% Define logging properties
log_path = ['./Logs/grind_' datestr(now, 'mmddyy_HHMM') '.txt'];
kv_serial.RecordMode = 'index';
kv_serial.RecordDetail = 'verbose';
kv_serial.RecordName = log_path;
% Open the serial port
fopen(kv_serial);
% Record the serial
record(kv_serial);
% Send a serial break
serialbreak(kv_serial, 1000);
Recently, MATLAB has stopped reading from the serial port about an hour into execution. Strangely, I can send commands to the device via MATLAB and have no problem doing so - it's just that the ValuesReceived property stops incrementing and MATLAB stops recognizing any communication from the PLC.
What's really annoying is that restarting MATLAB is the only way to reestablish a fully working connection.
I'm at my wits' end and would appreciate any ideas or help!
  2 Comments
Walter Roberson
Walter Roberson on 14 Dec 2015
If you can spare the time, it would be interesting to find out whether it happens if you are not recording.
sir_kitty
sir_kitty on 15 Dec 2015
Oh, that's a good idea. I'll try it out tomorrow morning!

Sign in to comment.

Answers (0)

Categories

Find more on Communications Toolbox in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!