Writing Non-Standard Characters – Re: Serial Communications

So, in my previous blog post I mentioned a friend was looking at reading some data over the serial port from a set of scales. He did however come up against a small problem, the scales needed to be set a command code before they would output the weight.

So a pure send -> receive relationship.

Of-course the next stumbling block is that they want a byte code of 5 to be sent to initiate the conversation, not so easy now 😦

Thankfully Jscript has a pretty easy way to deal with this situation, the String object has a method called fromCharCode() which will take a decimal value and spit out the character code.

An example here is outputting the character code 48 (which is the number 0) would look something like this:

var strCode2 : String = String.fromCharCode(48);
debug.WriteLine(strCode2);

Happy coding! 🙂

This entry was posted in Development, M3 / MoveX and tagged , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s