News:

  • June 25, 2026, 06:17:40 PM

Login with username, password and session length

Author Topic: RJ12 Serial Port Compatibility  (Read 32461 times)

Mike Nash

  • Hero Member
  • *****
  • Posts: 652
Re: RJ12 Serial Port Compatibility
« Reply #15 on: August 26, 2016, 11:42:28 AM »
The RST ST143 works great. The warning shows at the bottom of DmD then turns off when I reset it. The LastERR0-7 MEMCLEAR does clear the tags, just not the System Status messages.

It's pretty neat having the Do-more hunt down and find the communications settings when I change them on the fly at the device. If I could use variables for the parameters of SETUPSER that would make the code way easier/neater. There are quite a few possible combinations with baud rate, data bits, parity and stop bits. There are only 4 baud rates that overlap on this. The device is 300-9600 and Do-more is 1200-115200. So that is 4*2*3*2 = 48 SETUPSER instructions plus associated write and reads.

But even neater is that this part was just a play project. Communications I will need, automatic configuration was more of an "I wonder if.."

BobO, I hope the hardware testing is going well!


plcnut

  • Hero Member
  • *****
  • Posts: 814
    • premiersi.com
Re: RJ12 Serial Port Compatibility
« Reply #16 on: August 26, 2016, 02:02:35 PM »
If you use DEVWRITE then you can use a variable to control each of the serial port settings. The SETUPSER is nice, but DEVWRITE offers more flexibility.
Circumstances don't determine who we are, they only reveal it.

~Jason Wolthuis
Premier Systems Integration, LLC
http://premiersi.com

Mike Nash

  • Hero Member
  • *****
  • Posts: 652
Re: RJ12 Serial Port Compatibility
« Reply #17 on: August 26, 2016, 03:44:17 PM »
If you use DEVWRITE then you can use a variable to control each of the serial port settings. The SETUPSER is nice, but DEVWRITE offers more flexibility.

Yes, I see, thanks. That also answers my unasked question of how to read the current serial port settings (DEVREAD).

So I guess the question is whether I would burn through any non-volatile memory write life doing this too often in a worst case scenario.

BobO

  • Host Moderator
  • Hero Member
  • *****
  • Posts: 6161
  • Yes Pinky, Do-more will control the world!
Re: RJ12 Serial Port Compatibility
« Reply #18 on: August 27, 2016, 11:56:43 AM »
If I had a need to only occasionally send a parameter to a device, would a task work for this, or does it need to be a program?
You need to use a program.
A task is intended to only be active for a single scan (this can be bypassed using a YIELD or a looping instruction), and therefore is not intended to run multi-scan instructions.

This is true for multi-scan instructions, but DEVREAD/DEVWRITE are not multi-scan, so technically you could put them in a Task.


Quote
Second question, can I change the serial port settings on-the-fly (such as auto setup of comms looking for a response?)
This can be done using DEVWRITE, but (as I understand it) this is writing to the Do-more flash which has a finite number of writes.

DEVREAD and DEVWRITE are just driver property accessors, so they don't write to flash.
"It has recently come to our attention that users spend 95% of their time using 5% of the available features. That might be relevant." -BobO

Mike Nash

  • Hero Member
  • *****
  • Posts: 652
Re: RJ12 Serial Port Compatibility
« Reply #19 on: August 27, 2016, 12:34:26 PM »
DEVREAD and DEVWRITE are just driver property accessors, so they don't write to flash.

Fantastic, thanks!   That explains why nothing was mentioned about write limits anywhere.

"accessors" - I learned a new word today.  :)  OK, I probably haven't "learned" it yet, but it's a start.

BobO

  • Host Moderator
  • Hero Member
  • *****
  • Posts: 6161
  • Yes Pinky, Do-more will control the world!
Re: RJ12 Serial Port Compatibility
« Reply #20 on: August 27, 2016, 03:46:21 PM »
DEVREAD and DEVWRITE are just driver property accessors, so they don't write to flash.

Fantastic, thanks!   That explains why nothing was mentioned about write limits anywhere.

"accessors" - I learned a new word today.  :)  OK, I probably haven't "learned" it yet, but it's a start.

Spell check isn't happy with the word 'accessor', but it is a common term for a method that gets/sets a property in a class. We knew that we would want to tweak driver internals without using a dedicated instruction for each, so we built a general purpose instruction for reading and writing them. The nice part is that we can come back years later and add new accessors with virtually no development effort, which makes it far easier to say 'yes' to customer requests. We've already done several in the SMTP client device, and it wasn't hard to justify.
"It has recently come to our attention that users spend 95% of their time using 5% of the available features. That might be relevant." -BobO

Mike Nash

  • Hero Member
  • *****
  • Posts: 652
Re: RJ12 Serial Port Compatibility
« Reply #21 on: August 28, 2016, 06:34:55 PM »
It turns out I have only 4 baud rates that are compatible and only 3 possible data bit, parity, stop bit combinations for a total of 12 possibilities. It further turns out 8, none, 1 stop and 8, none, 2 stop bits are interchangeable for what I am doing (I got the correct response at 1 stop even if the device is set for 2 stop bits.)

What this meant was that the SETUPSER was quicker for the format and DEVWRITE was nicer for the baud rate.

(Hmm, as an aside, DmD 1.4.3 really doesn't like to open when Firefox has this forum open, very strange.)

[So I think the DmD issue may be more to do with not having the VPN connected when the last project opened was using it? Gotta check that more, but with the VPN connected first DmD works as usual. This even though I was only planning to do an offline check.]

I also discovered that $03 for the 12th character is not a solid way of determining if the response was good. If the port settings are wrong I can get this where it should never be. But if I allow 12 bytes to also be a completion, I may still be getting a bad response. I do know I should get @ as the 4th character for this response test. So does anyone have a really nifty bit of code for checking these 4 conditions are all true?

A) starts with $02
B) @ is 4th ASCII character ($40)
C) ends with $03
D) has a length of 12 characters inclusive.

I currently have $03 terminating the STREAMIN, STRSUB to get the 4th character (offset 3), STRCMP to see if it is @ and no check for $02 or length of 12.

A plcnut post reminded me of SS0.len so that will be easy to add. Gotta go, about to lose utilities.

I did a little more digging, STRGETB lets me put those 12 characters into a "buffer" that then lets me do simple = contacts on length, 1st, 4th and 12th characters as expected. This is closer to what I had in mind from BASIC days with LEFT$, MID$, RIGHT$ = those expected characters.

Still open for for more elegant solutions!

I haven't lost communications with it yet even though I have been randomly changing the device's port settings from a Data View via Do-more's serial port and they are both at the office and I am at home. Do-more has found the settings each time just fine. Not bad as long as I don't try to set below 1200 baud.  ;)
« Last Edit: August 28, 2016, 08:03:08 PM by Mike Nash »