About free serail port


kanber

Recommended Posts

Hi,

On com monitor screen when I put Output string "\x80\x01\x02\x00\x00\x29" and press to sent button it is working.

on sequence am I need to write like that;

device.AmlMasasiDevice.Write(chra({0x80,0x01,0x02,0x00,0x00,0x29}))

 

second quetion is I need to sent the string when users press and hold a button continuously. how can I do that?

 

Link to comment
Share on other sites

1st question: yes.  But make sure it is an actual x.  It might be the forum software, but it rendered 0x80 with a different character for the x.  It should be the letter x.

2nd question: do you want it to repeatedly send that string?  To do something that starts on mouse button down, and stops on mouse button up, use two Actions.  The first, with "Mouse Down" checked, should start a sequence using beginseq().  The second, without Mouse Down checked, should stop the sequence.  The sequence should have a loop and do whatever you want to do while the mouse it held down.

Link to comment
Share on other sites

1st: sorry, if you look in the forum post, at least on my screen the x shows up a little higher than a normal x.  I think it is just the forum software thinking it is a multiplication symbol, but I want to make sure you use an actual x, the letter, when you use it for hex.  Considering my post also has the raised x, I think you are just fine.

2nd: you can't really do it differently in event driven environments like Windows (and thus DAQFactory).  There is an event when the mouse button goes down, and another when it goes up.  There is nothing in between, so you have to implement it, and it needs to run in the background.  We could, I suppose, add a background thread, but that would just replicate something that you can already do easily in DAQFactory, with less flexibility.

Link to comment
Share on other sites

Hi,

another issues is when I sent 6 byte on monitor TX showing 5 byte. you can see attached file.

I need to sent data to device 6 byte with below format;

Byte 0 ID
Byte 1 command
Byte 2 key state
Byte 3 dummy
Byte 4 dummy
Byte 5 checksum

and device will answer me below format;

Byte 0: ID
Byte 1: command
Byte 2: option
Byte 3: checksum

 

ID is fixed x80. how can I catch anwser with check sum?( Xor data with 0xAA)

 

checksum (byte 3)


The checksum is formed by exclusively ordering all preceding bytes with the bit pattern 10101010 (0xAA):
for(tb_Cnt = 0; tb_Cnt< (EMPFA_BUFF_LAENGE - 1); tb_Cnt++)
{
      tb_CheckSumme ^= EmpfangsBuffer[tb_Cnt];
}

Ekran Alıntısı.JPG

Link to comment
Share on other sites

Actually, the output string is 6 bytes.  It is just that 0x38 is the ASCII code for the number 8.  That is why it reads \x008 at the end.  \x00 is the 5th byte, while 8 (ASCII) is the 6th byte.  You should, in general, always have "Display all chars as ASCII codes" checked when working with binary protocols.  Note also that 8 ASCII and 0x38 are the exact same thing and result in a single byte (0x38) being sent out the port.

Link to comment
Share on other sites

  • 3 weeks later...

Hi,

I have two quetions;

1- Is there any option to catch first character. we have ReadUntil command, But I need to catch if first character is like x80 then read 4 byte.

2- Can you help me calcuation checksum. there is 4 byte data. I need to calcute with first there byte with xor with xAA byte and check with 4.byte with is checksum from device.

The checksum is formed by exclusively ordering all preceding bytes with the bit pattern 10101010 (0xAA):
for(tb_Cnt = 0; tb_Cnt< (EMPFA_BUFF_LAENGE - 1); tb_Cnt++)
{
      tb_CheckSumme ^= EmpfangsBuffer[tb_Cnt];
}

Link to comment
Share on other sites

1) use read(1).  Then after you can use readUntil() to read the rest, or you could read(1), then read(4).  Read() will read the specified number of characters (within the timeout period) and remove them from the buffer.

2) the XOR operator in DAQFactory is #.  There is no #=, so you would have to do: tb_CheckSumme = tb_CheckSumme # EmpfangsBuffer[tb_Cnt]

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.