I implemented a few months ago a function that sends data from Matlab to a Weiss WSG50 gripper. This is a Robotic Gripper Tool and uses binary codes as commands. I established a connection with the tcpip function. I wrote my commands and sended them with ´fwrite´ as uint8-data to the gripper. My tcpip object is a client. The gripper a server. The gripper sucessful runs the command perfectly. Until here everthing works as I expected.
The Trouble begins, when I tryied to receive data back from the gripper. The gripper reacts with a awnser message on every sended command (Could be more then one message). But my ´BytesAvailable´ stays empty.
I know that could be diffcult to reproduce, because it may be necessary to have access to the gripper. But eventual I do something basic wrong with setting up the TCPIP object. I tryied already to use ´tcpclient´ but with this function sending is not working also.
%% WORKING PART
%Preparing the gripper
gripper = tcpip('172.16.6.72',1000);
gripper.OutputBufferSize = 3000;
gripper.ByteOrder = 'littleEndian';
gripper.Timeout = 1;
fopen(gripper);
%Command
release = [170; 170; 170; 38; 8; 0; 0; 0; 160; 64; 0; 0; 210; 67; 0; 0];
release = hex2dec(release);
fwrite(gripper, uint8(release), 'uint8');
fclose(gripper);
%% NOT WORKING PART
readdata = fread(gripper,gripper.BytesAvailable);
If ´BytesAvailable´ is empty it absolutly makes sense, that this is not working. No Data no reading. My Question is it a problem with the gripper or am I doing something totally wrong with the tcpip object configuration?