Sending non-printable ascii characters via serial port

Jay Hennessy tjay.hennessy at gmail.com
Wed Jul 9 18:59:04 UTC 2014


Paul,

So this method would send the binary equivalent of those hex values which 
represent ascii characters.

Do you know if/how Serial.WriteBytes is different from Serial.Write?

I would assume that either way the information is going to be sent in the 
form of bytes through the port. Is the protocol for how e-prime sends bytes 
different for one method vs. the other.
Or is WriteBytes the same as Write except one takes hexadecimal values and 
one the other takes string values then converts them to bytes?

Any wisdom you could pass on would be much appreciated once again.

Cheers,

J

On Saturday, June 28, 2014 6:54:17 AM UTC-4, Paul Groot wrote:

>
> Jay,
>
> You can use the WriteBytes function for this:
>
> Dim arrData(4) As Integer
> arrData(0) = 40
> arrData(1) = 30
> arrData(2) = 35
> arrData(3) = 30
> arrData(4) = &H2A
>
> Serial.WriteBytes arrData
>
> With some additional code you could make a nice function out of this that 
> automatically calculates and adds the checksum value.
>
> Best,
> Paul
>
>
>
> On 25 June 2014 22:20, Jay Hennessy <tjay.h... at gmail.com <javascript:>> 
> wrote:
>
>> Hi all,
>>
>> Maybe someone can help me with this problem.
>>
>> I want to send a string to a serial port to control a TMS machine during 
>> an EEG experiment. I already know how to send strings using Serial.Write
>>
>> The problem is that the standards for the TMS machine require the last 
>> character of the string to be a check bit. You calculate it by first adding 
>> up the hexadecimal equivalents of the other characters then taking the 
>> inverse. This is now your check bit or check character added to the end of 
>> the string.
>>
>> example: if i want to send @050
>>
>> ascii      hex
>>
>> @     =    40
>> 0       =    30
>> 5       =     35
>> 0       =     30
>>
>> 40+30+35+30 = D5
>>
>> so the inverse is = 2A
>>
>> and 2A in hex is * in ascii
>> so I would send the string @050* and everything should work.
>>
>> The problem is that if my check bit becomes a non-printable ascii 
>> character, how should I send it?
>>
>> for example my check bit might be 1C in hex which is 'file seperator' in 
>> ascii. This isn't a character I can send using Serial.Write in Eprime (at 
>> least that I know of).
>> Can anyone think of a way around this problem?
>> I might be able to send bits instead of a string. Is sending bits 
>> something Serial.Write can do? can eprime convert things to bits?
>>
>> Any help would be appreciated.
>>
>> Thanks
>>
>> jay
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "E-Prime" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to e-prime+u... at googlegroups.com <javascript:>.
>> To post to this group, send email to e-p... at googlegroups.com 
>> <javascript:>.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/e-prime/fb97098b-509e-403b-96a7-909c09c9ef67%40googlegroups.com 
>> <https://groups.google.com/d/msgid/e-prime/fb97098b-509e-403b-96a7-909c09c9ef67%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups "E-Prime" group.
To unsubscribe from this group and stop receiving emails from it, send an email to e-prime+unsubscribe at googlegroups.com.
To post to this group, send email to e-prime at googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/e-prime/36c2a30d-db0a-48b1-8e64-187a18b92292%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listserv.linguistlist.org/pipermail/eprime/attachments/20140709/a2d80f64/attachment.htm>


More information about the Eprime mailing list