|
Leif,If I read this correctly, the inputs and outputs are in character format as defined in REXX's X2B function. If so, a subprocedure like the following worked OK when I tested it.
P X2B b D X2B pi 8a D X 2a value D ds ds D a16 16 inz('0123456789ABCDEF') D arr1 1 dim(16) overlay(a16) D a64 64 inz('0000+ D 0001+ D 0010+ D 0011+ D 0100+ D 0101+ D 0110+ D 0111+ D 1000+ D 1001+ D 1010+ D 1011+ D 1100+ D 1101+ D 1110+ D 1111') D arr2 4 dim(16) overlay(a64) D i s 10i 0 D j s 10i 0 D string8 s 8 varying /free j = %lookup(%subst(X:1:1):arr1); string8 = arr2(j); j = %lookup(%subst(X:2:1):arr1); string8 += arr2(j); return string8; /end-free P X2B e Mel Rothman Mel Rothman, Inc. Leif Guldbrand wrote:
Hi, I receive some data from a industrial I/O box (Beckhoff BK9000) thru Modbus protocol over TCP/IP in my socket client program (thanks Scott :) One byte is the status of 8 input registres and is received in Hex from x'00' to x'FF'. I need to change this value into a binary string. An example.... I receive the value x'80' which should be converted to '1000 0000' and end up in a data structure with 8 fields. I've Googled around, but could only find the thing I want, doing it with REXX and the function X2B('C3') -> '11000011' I want to do this inside my program.... any help out there ??? Best regards, Leif
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.