serial communication

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

serial communication

iceyj21
still facing issues but now its with the srl_write function. Below is my code and the error it is giving if anyone could point me in the right direction. thank you.


code:
error:


_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: serial communication

mmuetzel
Octave language is not type sensitive. Write something like this to define your array of hex values:
pkt = [0xBB, 0x00, 0x08, 0x00, 0x00, 0x7E, 0x0B, 0x96];

Also, indices start with 1 (not with 0).
I do not know srl_write but there is a good chance it can send character vectors without a loop.

A good start for getting to know the basics of the language is reading (at least) the first chapter of the manual:
https://www.gnu.org/software/octave/doc/interpreter/

Just as a side note: You might reach more people willing to help if you sent your code and error messages as text instead of screenshots.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: serial communication

Andreas Weber-6
In reply to this post by iceyj21
Am 21.06.2017 um 07:31 schrieb Joe Rodrigues:
> still facing issues but now its with the srl_write function.

Please please please add your code and error messages as plain text and
not as screenshots. Thank you

-- Andy



_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: serial communication

iceyj21
In reply to this post by iceyj21
Heres my code. Using cutecom to monitor the serial output of the rfid reader that I'm sending the hex values to I found that its receiving the "auto_read" command and then sending hex values out. What I'm facing now is the inability to read those hex values with srl_read. the port is correct and there is data that should be received but I'm not sure why octave isn't. When looking at the variable values "tag" isn't being assigned anything form the srl_write function.

clc;
clear;

s3 = serial("/dev/cu.SLAB_USBtoUART",115200,2);
set(s3, "dataterminalready", "off");
set(s3, "requesttosend", "off");


tag = [];



pkt = [0xBB, 0x00, 0x08, 0x00, 0x00, 0x7E, 0x0B, 0x96];

auto_read = [0xBB,0x00,0x38,0x00,0x05,0x02,0x00,0x00,0x00,0x00,0x7E,0x51,0x7A];






i=1;
j=1;

while (i<9)


srl_write(s3,uint8(pkt(i)));

i = i+1;
srl_flush(s3);
endwhile
pause(1);
while (j<14)


srl_write(s3,uint8(auto_read(j)));

j = j+1;
srl_flush(s3);
endwhile  

disp(pkt);

disp(auto_read);

pause(2);

[tag,n] = srl_read(s3,1000000);
tag_hex = dec2hex(tag,1000000);

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: serial communication

Andreas Weber-6
I've also answered to your other, almost same question. I'll stick know
on this thread.

Am 22.06.2017 um 09:17 schrieb iceyj21:

> Heres my code. Using cutecom to monitor the serial output of the rfid reader
> that I'm sending the hex values to I found that its receiving the
> "auto_read" command and then sending hex values out. What I'm facing now is
> the inability to read those hex values with srl_read. the port is correct
> and there is data that should be received but I'm not sure why octave isn't.
> When looking at the variable values "tag" isn't being assigned anything form
> the srl_write function.
>
> ...
>
> s3 = serial("/dev/cu.SLAB_USBtoUART",115200,2);

Try to increase the timeout (2 -> 20)

> set(s3, "dataterminalready", "off");
> set(s3, "requesttosend", "off");

Not needed since it's the default setting

> pkt = [0xBB, 0x00, 0x08, 0x00, 0x00, 0x7E, 0x0B, 0x96];

Does this include the correct CRC16?

> srl_write(s3,uint8(pkt(i)));

Just use srl_write(s3,uint8(pkt)); no need for the loop

> srl_write(s3,uint8(auto_read(j)));

Why do you send two commands?

> [tag,n] = srl_read(s3,1000000);

As I said in the other thread: make a hardware loopback between RX and
TX (pin 2+3) and see if you receive the same string as you are sending.

-- Andy


_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: serial communication

iceyj21
Andreas Weber-6 wrote
I've also answered to your other, almost same question. I'll stick know
on this thread.

Am 22.06.2017 um 09:17 schrieb iceyj21:
> Heres my code. Using cutecom to monitor the serial output of the rfid reader
> that I'm sending the hex values to I found that its receiving the
> "auto_read" command and then sending hex values out. What I'm facing now is
> the inability to read those hex values with srl_read. the port is correct
> and there is data that should be received but I'm not sure why octave isn't.
> When looking at the variable values "tag" isn't being assigned anything form
> the srl_write function.
>
> ...
>
> s3 = serial("/dev/cu.SLAB_USBtoUART",115200,2);

Try to increase the timeout (2 -> 20)

> set(s3, "dataterminalready", "off");
> set(s3, "requesttosend", "off");

Not needed since it's the default setting

> pkt = [0xBB, 0x00, 0x08, 0x00, 0x00, 0x7E, 0x0B, 0x96];

Does this include the correct CRC16?

> srl_write(s3,uint8(pkt(i)));

Just use srl_write(s3,uint8(pkt)); no need for the loop

> srl_write(s3,uint8(auto_read(j)));

Why do you send two commands?

> [tag,n] = srl_read(s3,1000000);

As I said in the other thread: make a hardware loopback between RX and
TX (pin 2+3) and see if you receive the same string as you are sending.

-- Andy


_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
the crc is correct.The reason for the two commands are for two different functions. The first one labeled "pkt" is to reset the reader, and the second "auto_read" is to enable the auto read mode on the reader. Both functions are working properly, when I connect to the reader using a serial port utility program I'm able to receive the output so the transmission from octave to the reader is functioning properly. the issue I'm facing now is receiving data from the reader.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: serial communication

iceyj21
ah i changed the timeout time to a greater value and its working! thank you so much!
Loading...