在ABAP中从mscomm读取数据 [英] Reading data from mscomm in ABAP

查看:122
本文介绍了在ABAP中从mscomm读取数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试读取通过 -port-by-using-mscomm32-ocx rel = nofollow noreferrer> MSCOMM32 对象。

I'm trying to read data sent from serial port via MSCOMM32 object.

我得到的是 ##

首先,我将十六进制转换为字符串并发送到COMM端口:

First I convert hex into string and send to COMM port:

DATA : xSTX TYPE xstring VALUE '02'.
DATA : sSTX TYPE string.

CALL FUNCTION 'HR_KR_XSTRING_TO_STRING'
EXPORTING
 in_xstring = xSTX
 IMPORTING
 out_string = sSTX. "this value is now # but still understood by the device

SET PROPERTY OF O_OBJ 'Output' =  sSTX .

然后连接到串行端口的计算机将给出响应。我使用以下代码读取数据:

And then the machine attached to serial port will give a response. I read the data using this code below:

  Data strmsg Type string.
  DO 10 TIMES.
    GET PROPERTY OF o_obj 'InBufferCount' = wa_buffer.
    If wa_buffer > 0.
        GET PROPERTY OF o_obj 'Input' =  strmsg.
    Endif.
  ENDDO.

我可以看到使用监视设备的响应,但是当我将此 ## 转换为十六进制时,我得到的输入仅为 ## 那么我会得到 0202

I can see the response using monitoring device but the input that I get was only ##, when I convert this ## into hex then I would get 0202.

我已经正确地进行了所有设置,因为我能够发送数据并激活机器,但是我仍然无法转换响应。

I already did all the settings correctly because I'm able to send the data and activate the machine, but I'm still not able to translate the response.

我有一个使用.NET的旧版软件,它可以完美地读取数据。相同的响应数据。

I have a legacy software using .NET and it can read the data perfectly, using the same response data.

另一个奇怪的事情是 sSTX 的值是,但是我

Another strange thing was the value of sSTX is # but I don't bother it too much because it's understood by the device.

期望的输出是(从监视器获取的)

The expected output is (taken from monitor)

<ACK><STX><STX><NUL><SOH>01000000000000000000000000                       P3                                                                                                                                                    <ETX>

但是我得到的只是060202,这是

But all I get was 060202 which is

<ACK><STX><STX> 

文本主体不在同一空间。

somehow the text body is not in the same space.

我知道答案是存在的,但我无法在数周内弄清楚。

I know the answer is there but I just can't figure it out for weeks. very weird.

推荐答案

我找到了答案。

设置将inputlen属性设置为4。
解决了问题。

set the inputlen property to 4. solve the problem.

这篇关于在ABAP中从mscomm读取数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆