[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

API Frames in Serial_Write

From: Grant Wise
Subject: API Frames in Serial_Write
Date: Sat, 7 Mar 2020 10:19:26 -0600


I am attempting to write commands to an Xbee module through serial in Octave. Problem is, to communicate this xbee needs to receive an API packet (a vector of Hex values). Matlab appears to have a solution for this, see:

However, it appears that srl_write will not accept vectors. Any suggestions? Below is my code:

pkg load instrument-control

if (exist("serial") != 3)
  disp("No serial support")

s1 = serial("COM4")
set(s1, 'baudrate', 115200);    
set(s1, 'bytesize', 8);        
set(s1, 'parity', 'n');        
set(s1, 'stopbits', 1);        
set(s1, 'timeout', 123);    

frame(1,:) = '7E';                                      % Frame Class Name for reading only
frame(2,:) = '00';                                     % length 1
frame(3,:) = '10';                % length 2
frame(4:5,:) = ['10';'01'];                        % type & ID
frame(6:13,:) = ['00';'13';'A2';'00';'41';'95';'83';'04'];    %64bit address
frame(14:15,:) = ['FF';'FE'];       %16bit address
frame(16,:) = '00';
frame(17,:) = '00';
frame(18:19,:) = ['48';'69'];  %data
frame(20,:) = '2E';   %sum

frame = hex2dec(frame)

ts = srl_write(s1, frame)   %error ->  Invalid call to srl_write.

%fwrite(s1, frame, 'uint8')       <- this didnt work either  

Thanks for the help.
Grant Wise

reply via email to

[Prev in Thread] Current Thread [Next in Thread]