Serial Port help

Discussion in 'C-Bus Serial Protocols' started by jasonson, Jul 15, 2017.

  1. jasonson

    jasonson

    Joined:
    Feb 17, 2014
    Messages:
    34
    Likes Received:
    6
    Location:
    Brisbane
    For the life of me I cannot get the serial communications in Logic to work either on the unit itself or in simulation mode on the PC.

    I can't event get logic to do this basic step:

    Code:
    OpenSerial(1,1,9600,8,1,0,0);
    WriteSerial('UK001'#13);
    CloseSerial(1);
    
    The unit (Paradox alarm panel PRT3) is connected to my laptop on COM1 via USB Serial Adapter and i can manually send the UK001 command via a terminal and it will respond as intended.

    I am so confused as to why this simply wont work from logic.
     
    jasonson, Jul 15, 2017
    #1
    1. Advertisements

  2. jasonson

    Damaxx

    Joined:
    May 12, 2008
    Messages:
    210
    Likes Received:
    35
    From the tinkering I have done with serial, you need to add the magic line
    Code:
    waitUntil(clientSocketConnected(1));
     
    Damaxx, Jul 15, 2017
    #2
    1. Advertisements

  3. jasonson

    Ashley

    Joined:
    Dec 1, 2005
    Messages:
    1,267
    Likes Received:
    130
    Location:
    Adelaide, Australia
    The write doesn't wait until it's done, so when you close the port straight away it will cancel the write in progress.

    Open the port in the initialization section. You don't need to close it.

    You don't need to wait after you open the port as it happens straight away (unlike TCP connections that take time). The waitUntilCLientSocketConnected is for tcp connections only, not serial.
     
    Ashley, Jul 15, 2017
    #3
  4. jasonson

    djaggar

    Joined:
    Jul 18, 2009
    Messages:
    66
    Likes Received:
    0
    Location:
    New Zealand
    djaggar, Jul 16, 2017
    #4
  5. jasonson

    jasonson

    Joined:
    Feb 17, 2014
    Messages:
    34
    Likes Received:
    6
    Location:
    Brisbane
    I read that and modified the handler to work on serial cheers.

    Works like a treat in a PAC but i think the rs-232 port on my spectrum is cooked.

    I cannot get it to output a single byte. From the 3.5mm jack, when plugged into the PC via USB-> serial i can interact perfectly with the PRT3 module.

    Connected to the spectrum does nothing at all. Screen is only a year old.
     
    jasonson, Jul 30, 2017
    #5
  6. jasonson

    NickD Moderator

    Joined:
    Nov 1, 2004
    Messages:
    1,418
    Likes Received:
    47
    Location:
    Adelaide
    Have you checked the pinout of the connector?

    The cable for the Spectrum is the wrong gender for most applications, which means not only does the connector gender need to be changed but the TX/RX pins need to be swapped..

    Here's a nice application note that the Square-D guys did for it.

    Nick
     
    NickD, Jul 30, 2017
    #6
  7. jasonson

    jasonson

    Joined:
    Feb 17, 2014
    Messages:
    34
    Likes Received:
    6
    Location:
    Brisbane
    I have checked it many times as I do alot of serial comms work with PLCs. It is a very easy mistake to make. However, I have proven that the cable installed works as I can use a 3.5mm gender bender to allow me to plug an rs232 -> 3.5mm stereo jack into it and using putty and hyperterminal I am able to send and receive commands from the PRT3 module.

    When it is plugged into the spectrum, I get nothing. I have even changed the spectrum from master to slave, tried changing the Tx/Rx lines in both master and slave mode and still get nothing. :mad:
     
    jasonson, Jul 31, 2017
    #7
  8. jasonson

    jboer

    Joined:
    Apr 27, 2012
    Messages:
    458
    Likes Received:
    35
    Location:
    Sydney
    Yeah, I have found the RS232 transcevers or ect or something is bad in the Spectrums, I have had more than one unit where the serial doesn't work out of the box, some of them are fine some of them just arn't. This is using the 'official' serial cable too.
     
    jboer, Jul 31, 2017
    #8
  9. jasonson

    jasonson

    Joined:
    Feb 17, 2014
    Messages:
    34
    Likes Received:
    6
    Location:
    Brisbane
    What a bugger. You'd think on ~$1000+ piece of hardware a simple RS232 transceiver would be bullet proof.

    I have a few TCP RS232 modules kicking around so I will use one of those and run the code from the wiser instead now I guess.
     
    jasonson, Jul 31, 2017
    #9
  10. jasonson

    NickD Moderator

    Joined:
    Nov 1, 2004
    Messages:
    1,418
    Likes Received:
    47
    Location:
    Adelaide
    I would expect so too (even though it wasn't one of my designs), and I'm disappointed to hear that people have had units that don't work out of the box. Unfortunately this is the first I've heard of it.

    As design engineers we hope that when stuff like this happens, that it gets reported, because if we don't know about it we can't do anything about it.

    Nick
     
    NickD, Jul 31, 2017
    #10
    CrazyDave likes this.
  11. jasonson

    jasonson

    Joined:
    Feb 17, 2014
    Messages:
    34
    Likes Received:
    6
    Location:
    Brisbane
    I might book a time with Keenan at Schneider Brisbane and get him to verify that my port is buggered and if that's the case, I'll get it swapped under warranty and try again with the new one.
     
    jasonson, Jul 31, 2017
    #11
  12. jasonson

    jboer

    Joined:
    Apr 27, 2012
    Messages:
    458
    Likes Received:
    35
    Location:
    Sydney
    It is one of those things I guess, as a design person myself I feel your pain, at the end of the day, if it doesn't get captured under the warranty process then it is likely to get lost. Unfortunately this does depend on a lot of people in the middle, like the wholesaler and the Schneider/Clipsal Warehouse ect.
     
    jboer, Aug 1, 2017
    #12
  13. jasonson

    ashleigh Moderator

    Joined:
    Aug 4, 2004
    Messages:
    2,363
    Likes Received:
    11
    Location:
    Adelaide, South Australia
    Agree with your disappointment.

    A few years back I had a design with a similar issue: a lot of RS-232 ports were knackered immediately after manufacture. The factory test people were most unhappy and blamed it all on a design fault. Something like 30% of everything built had to be reworked.

    Turned out that the next batch built were all ok. That initial high failure rate was a reel of dodgy RS-232 converter IC's. Of course dealing with the maker of the components gets hard when they are bad and have all been built into products and shipped.

    My reason for telling this is that you feel aggrieved, and rightly so. The manufacturer / factory may not know anything about it, and furthermore the control of that may also be completely out of their hands. It's disappointing but happens.
     
    ashleigh, Aug 2, 2017
    #13
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.