Developer Portal Community

    cancel
    Showing results for 
    Search instead for 
    Did you mean: 
    SOLVED

    Serial Channel only reads 22 bytes, even though the device sends more

    Serial Channel only reads 22 bytes, even though the device sends more

    MarvinW
    Long-established Member

    Hello,

    I have the following problem with a unit that I programmed for a device connected with RS485.

    I am using an EL6022 and the matching Peripheral version 2.0.5.0. I am only using the first channel and it is configured as RS485 in the OES parameters.

    I open the channel like this:

    _parCfg.iSerialStream.Open(OpconSerialBaudRate.BAUD_9600, OpconSerialDataFrame.FRAME_8E1, OpconSerialHandShakeType.NO_HANDSHAKE);

    I successfully send 14 bytes to the device and the device responds according to its protocol documentation. In order to receive the response, I use:

    _parCfg.iSerialStream.Read(ADR(_receiveBuffer), 23, _bytesRead, _timeout);

    When the Read() method returns OK, the value in _bytesRead is only 22 though, this is my problem. I checked the Input variables of the serial terminal and I can see that the 23rd byte that the device sent me actually sits in the Data In 0 with Input length set to 1. So the device seems to work correctly, the Beckhoff terminal seems to work correctly, but the EL6022 peripheral seems unable to read more than 22 bytes, which is probably because that's how much data the serial terminal catches with its input variables in a single go.

    I tried different handshake mechanisms in the Open() parameter but they seem to have no effect (... are they even used with RS485 in general?). I also made sure that the device's parameters are matching the baud rate and parity settings. But could not get the 23 byte response to work correctly with the Nexeed objects.

    The device supports another protocol that only has a 19 byte response. If I use this one then the message fits into the buffer and the entire communication works. So it does not seem to be a problem of the device and probably not in my application either.

    Are there any known solutions to this problem? I am curious what the root cause is and how to eliminate it, because I really want to use the 23 byte version of the protocol.

    6 REPLIES 6

    maj9bj
    Long-established Member

    Hello, is there any documentation or example of usage for IOpconSerialStream?

    SteffenR-
    Community Moderator
    Community Moderator

    You can find an example on the Bosch internal release server (...\Nexeed\Automation\ControlPlus\Samples\Serial Example\V1.0).

    If you do not have access and want to have the example, please contact our helpdesk.

    Icon--AD-black-48x48Icon--address-consumer-data-black-48x48Icon--appointment-black-48x48Icon--back-left-black-48x48Icon--calendar-black-48x48Icon--center-alignedIcon--Checkbox-checkIcon--clock-black-48x48Icon--close-black-48x48Icon--compare-black-48x48Icon--confirmation-black-48x48Icon--dealer-details-black-48x48Icon--delete-black-48x48Icon--delivery-black-48x48Icon--down-black-48x48Icon--download-black-48x48Ic-OverlayAlertIcon--externallink-black-48x48Icon-Filledforward-right_adjustedIcon--grid-view-black-48x48IC_gd_Check-Circle170821_Icons_Community170823_Bosch_Icons170823_Bosch_Icons170821_Icons_CommunityIC-logout170821_Icons_Community170825_Bosch_Icons170821_Icons_CommunityIC-shopping-cart2170821_Icons_CommunityIC-upIC_UserIcon--imageIcon--info-i-black-48x48Icon--left-alignedIcon--Less-minimize-black-48x48Icon-FilledIcon--List-Check-grennIcon--List-Check-blackIcon--List-Cross-blackIcon--list-view-mobile-black-48x48Icon--list-view-black-48x48Icon--More-Maximize-black-48x48Icon--my-product-black-48x48Icon--newsletter-black-48x48Icon--payment-black-48x48Icon--print-black-48x48Icon--promotion-black-48x48Icon--registration-black-48x48Icon--Reset-black-48x48Icon--right-alignedshare-circle1Icon--share-black-48x48Icon--shopping-bag-black-48x48Icon-shopping-cartIcon--start-play-black-48x48Icon--store-locator-black-48x48Ic-OverlayAlertIcon--summary-black-48x48tumblrIcon-FilledvineIc-OverlayAlertwhishlist