this is BA-88A, Semi-Auto Chemistry Analyzer.
The owner of this machine asked me to create a software that transfered data from this machine to the computer
This machine uses the serial port (RS-232) to do this job , in the form of a char array (HL7)
I completed the work easily, to convert the results of each patient individually
But the problem is that the machine manufacturer, states that the data can be transferred to several patients at once.
We can select data for multiple patients at once
but during conversion, only one result reaches
I thought the mistake was in the program I made.
I've tried several programs ready from the Internet, but only one result at a time.
Apparently, the machine stays in a state of waiting for some time, then a message appears error: transfer data failed
Maybe the machine is waiting for a message from the data receiver, to complete the conversion, maybe
Any old ideas, suggestions, or experience?
ComThread1 PROC ofs___
local L_handle :DWORD
local L_NumberOfBytesRead :DWORD
local lpEvtMask :DWORD
local lpError :DWORD
local W_ReadBuf :DWORD
local L_bIndexWR :DWORD
local L_ReadBuffer_ [1024]:DWORD
local __r :DWORD
MOV EAX,ofs___
MOV EAX,DWORD PTR [EAX+4]
mov L_handle, EAX ; save the handle
invoke SetCommMask, L_handle, EV_RING or EV_BREAK or EV_CTS or EV_DSR or EV_DSR or EV_RLSD or EV_RXFLAG or EV_TXEMPTY or EV_RXCHAR OR EV_ERR
;------------------------------------------------------
MOV ECX,L_handle ; get the handle
_WHILE:
invoke WaitCommEvent, L_handle, ADDR lpEvtMask, NULL
TEST EAX,EAX
JNZ @F
invoke crt_printf,cfm$("WaitCommEvent failed")
jmp ExitComThread
@@:
.IF lpEvtMask == EV_ERR
invoke crt_printf,cfm$(" ..Error.. ")
invoke ClearCommError, L_handle, ADDR lpError, NULL
.elseif lpEvtMask == EV_RING
invoke crt_printf,cfm$(" ring Event"); }
.elseif lpEvtMask == EV_BREAK
invoke crt_printf,cfm$(" break Event"); }
.elseif lpEvtMask == EV_CTS
invoke crt_printf,cfm$(" cts Event"); }
.elseif lpEvtMask == EV_DSR
invoke crt_printf,cfm$(" dsr Event"); }
.elseif lpEvtMask == EV_RLSD
invoke crt_printf,cfm$(" rlsd Event"); }
.elseif lpEvtMask == EV_RXFLAG
invoke crt_printf,cfm$(" rxflag Event"); }
.elseif lpEvtMask == EV_TXEMPTY
invoke crt_printf,cfm$(" txempty Event"); }
.elseif lpEvtMask == EV_RXCHAR
.WHILE TRUE
MOV W_ReadBuf,0
invoke ReadFile, L_handle, ADDR W_ReadBuf,1, ADDR L_NumberOfBytesRead, NULL ; Read in one DWORD from the serial port
mov eax,L_NumberOfBytesRead
.BREAK .IF L_NumberOfBytesRead == 0
.if W_ReadBuf==01CH;; end of MSH message
mov __r,1
.endif
lea eax,L_ReadBuffer_
lea ebx,W_ReadBuf
add eax,L_bIndexWR
mov cl,byte ptr [ebx]
.if cl==07CH ; Field
mov cl,0
.endif
mov byte ptr [eax],cl
inc L_bIndexWR
invoke crt_printf,cfm$(",0%XH"), W_ReadBuf
.ENDW
.if __r ==1 ; end of MSH message
mov __r,0
invoke ParceBuffer,addr L_ReadBuffer_
.endif
.else
invoke crt_printf,cfm$(" else Event %d ") ,lpEvtMask
.ENDIF
JMP _WHILE
ExitComThread:
invoke CloseHandle, L_handle ; close this port
MOV EAX,ofs___
MOV DWORD PTR [EAX+4],0 ; clear handle
ret
ComThread1 endp
Hexadecimal message:
;BH,4DH,53H,48H,7CH,5EH,7EH,5CH,26H,7CH,7CH,7CH,7CH,7CH,32H
;,30H,31H,39H,30H,38H,30H,37H,30H,34H,35H,30H,32H,37H,7CH,7CH,4FH,52H,55H,5EH,52H
;,30H,31H,7CH,34H,31H,7CH,50H,7CH,32H,2EH,33H,2EH,31H,7CH,7CH,7CH,7CH,30H,7CH,
;7CH,41H,53H,43H,49H,49H,7CH,7CH,7CH,DH,50H,49H,44H,7CH,34H,31H,7CH,7CH,7CH,7CH,7CH
;,7CH,32H,30H,31H,39H,30H,31H,30H,31H,30H,30H,30H,30H,30H,30H,7CH,4FH,7CH,7CH,7CH,7CH
;,7CH,7CH,7CH,7CH,7CH,7CH,7CH,7CH,7CH,7CH,7CH,7CH,7CH,7CH,7CH,7CH,7CH,7CH,7CH
;,DH,4FH,42H,52H,7CH,34H,31H,7CH,7CH,35H,7CH,5EH,7CH,4EH,7CH,7CH,32H,30H,31H,39H
;,30H,38H,30H,36H,30H,30H,30H,30H,30H,30H,7CH,7CH,7CH,7CH,7CH,7CH,7CH,32H,30H,31H
;,39H,30H,38H,30H,36H,30H,30H,30H,30H,30H,30H,7CH,7CH,7CH,7CH,7CH,7CH,7CH,7CH,7CH
;,7CH,7CH,7CH,7CH,7CH,7CH,7CH,7CH,7CH,7CH,7CH,7CH,7CH,7CH,7CH,7CH,7CH,7CH,7CH,7CH
;,7CH,7CH,7CH,7CH,7CH,DH,4FH,42H,58H,7CH,31H,7CH,4EH,4DH,7CH,7CH,43H,52H,45H,41H,
;7CH,31H,32H,2EH,32H,31H,30H,30H,30H,30H,7CH,31H,7CH,7CH,4EH,7CH,7CH,7CH,46H,7CH,
;7CH,31H,32H,2EH,32H,31H,30H,30H,30H,30H,7CH,32H,30H,31H,39H,30H,38H,30H,36H,30H,
;30H,30H,30H,30H,30H,7CH,7CH,7CH,7CH,DH,4FH,42H,58H,7CH,32H,7CH,4EH,4DH,7CH,7CH,50H
;,52H,4FH,20H,20H,32H,34H,68H,7CH,39H,37H,2EH,30H,30H,30H,30H,30H,30H,7CH,31H,7CH
;,7CH,4EH,7CH,7CH,7CH,46H,7CH,7CH,39H,37H,2EH,30H,30H,30H,30H,30H,30H,7CH,32H,30H
;,31H,39H,30H,38H,30H,36H,30H,30H,30H,30H,30H,30H,7CH,7CH,7CH,7CH,DH,1CH,DH
ASCII message:
?MSH|^~\&|||||20190806193603||ORU^R01|9|P|2.3.1||||0||ASCII
|||?PID|9||||||20190101000000|O|||||||||||||||||||||||?OBR|9||2|^|N||20190806000
000|||||||20190806000000||||||||||||||||||||||||||||||||||?OBX|1|NM||AST|47.0000
00|16||N|||F||47.000000|20190806000000||||?OBX|2|NM||ALP|133.000000|16||N|||F||1
33.000000|20190806000000||||?OBX|3|NM||DBIL|5.800000|1||N|||F||5.800000|20190806
000000||||?OBX|4|NM||CREA|13.820000|1||N|||F||13.820000|20190806000000||||?OBX|5
|NM||PHOS|43.370000|1||N|||F||43.370000|20190806000000||||?OBX|6|NM||PRO 24h|-5
4.000000|1||N|||F||-54.000000|20190806000000||||???