News:

  • February 10, 2025, 11:46:37 PM

Login with username, password and session length

Author Topic: StreamIn data format  (Read 3735 times)

sgsims

  • Hero Member
  • *****
  • Posts: 127
StreamIn data format
« on: March 27, 2024, 07:19:47 AM »
Hello:

Can the StreamIn instruction capture data in a string literal format in addition to ASCII Hex format?  For example if I want someone to send me a "False" string will either of these formats work?

0x460x410x4c0x530x450xa

"FALSE"0x0a

Thx

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3724
    • Host Engineering
Re: StreamIn data format
« Reply #1 on: March 27, 2024, 08:55:35 AM »
Hello:

Can the StreamIn instruction capture data in a string literal format in addition to ASCII Hex format?  For example if I want someone to send me a "False" string will either of these formats work?

0x460x410x4c0x530x450xa

"FALSE"0x0a

Thx

It just captures BYTEs into a buffer or string.  No formatting.  If there is any formatting, it must be done by the device SENDING the data (e.g. Modbus has a binary form RTU and an ASCII form, although not many devices send out ASCII any longer).

Regardless, put it in a STRING e.g. SS0 or SL0 if it's long, then utilize STRFIND to find "FALSE" or "TRUE" or "HLO" or whatever and other String functions (e.g. STRSUB to get a substring STR2INT to convert text to its numeric equivalent, e.g. "123" is 123, et. al.

What's best for getting good answers, get the ENTIRE contents of the STREAMIN packet into a String, then post the QUOTED FORMAT contents here, e.g.
"FALSE,1,2$0A$0D" (whatever)

2 or 3 examples will be helpful.  OR if there is a .pdf that describes the format of the data from the sending device, that would be best (grammar is one thing, semantics is the other).

sgsims

  • Hero Member
  • *****
  • Posts: 127
Re: StreamIn data format
« Reply #2 on: March 27, 2024, 09:40:46 AM »
Yup?the problem I?m having is the data being sent that I am attempting to capture using the STREAMIN instruction is throwing the ?On Error? jump to stage bit to go high so I can?t get the data into the SS1 memory location I specified in the instruction.

My assumption was the error was due to the format of the string being sent.  The sendor says he is sending me False\r . In reality I don?t know what sort of bytes he is sending because I can?t see it in SS1 due to the error.

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3724
    • Host Engineering
Re: StreamIn data format
« Reply #3 on: March 27, 2024, 09:47:42 AM »
take a screen shot of the whole rung of your STREAMIN instruction.  The Termination character should be just 1 exact character, and make it $0D (CR or \r)

sgsims

  • Hero Member
  • *****
  • Posts: 127
Re: StreamIn data format
« Reply #4 on: March 27, 2024, 10:41:57 AM »
Here you go.


franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3724
    • Host Engineering
Re: StreamIn data format
« Reply #5 on: March 27, 2024, 11:02:56 AM »
Hmm... that looks ok.

So S10 is turning ON, not S6?

Greg

  • HostTech
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 694
  • Hmmm...
    • Host Engineering, Inc.
Re: StreamIn data format
« Reply #6 on: March 27, 2024, 11:23:46 AM »
sgsims, you should not execute the STREAMIN until you have data in the buffer. So, before executing that Stage, wait until the .InQueue has a value greater than zero in it.
There are two types of people in the world; those that can extrapolate from incomplete data sets.

sgsims

  • Hero Member
  • *****
  • Posts: 127
Re: StreamIn data format
« Reply #7 on: March 27, 2024, 05:15:39 PM »
franji...yes S10 is turnng on not S6......


sgsims

  • Hero Member
  • *****
  • Posts: 127
Re: StreamIn data format
« Reply #8 on: March 28, 2024, 03:28:02 PM »
So at the end of the day if I am asking someone to send me string that I can capture successfully with the STREAMIN instruction am I really saying send me the binary equivalent of the ascii character they intend to communicate?  I guess I?m assuming that the error was being generated as a result of bad data format.  But then I?m thing that no matter what they send is seen by the instruction as a binary bit pattern so that would give me the correct data would result in a successful communication as far as the STREAMIN instruction goes.

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3724
    • Host Engineering
Re: StreamIn data format
« Reply #9 on: March 28, 2024, 03:31:22 PM »
So at the end of the day if I am asking someone to send me string that I can capture successfully with the STREAMIN instruction am I really saying send me the binary equivalent of the ascii character they intend to communicate?  I guess I?m assuming that the error was being generated as a result of bad data format.  But then I?m thing that no matter what they send is seen by the instruction as a binary bit pattern so that would give me the correct data would result in a successful communication as far as the STREAMIN instruction goes.

Yes.  Have you tried Greg's suggestion?  I think that is your issue.

sgsims

  • Hero Member
  • *****
  • Posts: 127
Re: StreamIn data format
« Reply #10 on: March 28, 2024, 04:42:26 PM »
I didn?t try Greg?s suggestion as the program has been in service for over 6 years and working like a champ.  The issue now stems from a change in the customer?s ERP who I am communicating with.

That being said Greg?s suggestion is a good one that I will implement in this program.

Now I think the issue might be the bit pattern being used for the delimiter.

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3724
    • Host Engineering
Re: StreamIn data format
« Reply #11 on: March 28, 2024, 04:59:34 PM »
Now I think the issue might be the bit pattern being used for the delimiter.

The format of the message is important.  If it is no longer terminated with just a CR (possibly CR/LF?), that would require a tweak to the STREAMIN instruction.

If you can hook up a communication analyzer - there's PC software out there that can do it - to see exactly what is being sent.

Double check the baud rate, data bits, parity settings, etc. on BOTH sides.  Cabling could be in question, handshake, et. al.

sgsims

  • Hero Member
  • *****
  • Posts: 127
Re: StreamIn data format
« Reply #12 on: March 28, 2024, 05:16:45 PM »
The message is still being terminated, or at least attempted to terminate, with a CR but could be the bit pattern used to send that character.  I will look into the analyzer and check the parity,  stop bits etc.  I assumed all of that was fine because we were able to send the host a string without issue.

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3724
    • Host Engineering
Re: StreamIn data format
« Reply #13 on: March 29, 2024, 11:23:09 AM »
I assumed all of that was fine because we were able to send the host a string without issue.

STREAMOUT will send with success regardless of whether it was received or not, or whether baud rate/parity etc. are correct on the receiving side.  You are doing raw comm, not a formal protocol in firmware like MRX/MWX where there are rules and handshaking and timeout behaviors in the firmware state machine can report more valid success/error.

sgsims

  • Hero Member
  • *****
  • Posts: 127
Re: StreamIn data format
« Reply #14 on: March 29, 2024, 11:32:29 AM »
Thanks Franji,

So the Error gets thrown with the STREAMIN instruction if the comm was not complete which could be many things including the two I am focusing on now?
1- Proper Delimiter
2-RS232 Config stuff..STop Bit,  PArity etc.

Thanks for all the help with this!