Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 17:11 11 May 2025 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : Sending and receivin hex using Serial Com

     Page 2 of 2    
Author Message
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9489
Posted: 08:31pm 03 Jul 2014
Copy link to clipboard 
Print this post

Acknowledged - was thinking that PLAY and STOP was a little in the grey area myself...
Smoke makes things work. When the smoke gets out, it stops!
 
viscomjim
Guru

Joined: 08/01/2014
Location: United States
Posts: 925
Posted: 02:38am 04 Jul 2014
Copy link to clipboard 
Print this post

In sticking with sending hex commands used in the data sheet, I tried these two methods...

INPUT A$
X$ = "&H" + A$
PRINT #1, CHR$(X$);

ERROR: EXPECTED A NUMBER

Then this one

INPUT A$
X$ = "&H" + A$
PRINT #1, CHR$(VAL(X$));

and that worked. Now on to converting the responses. Really, for what I am doing, I only need to read back the volume setting since that just steps up and down. You can't set the volume by sending a level command, only + and - steps. So I would read that first and then step up or down from that. I guess for certain applications, it would be nice to read the total track time, number of files, and current time of track. So I'm thinking that the responses should be converted from incoming hex to decimal to make it easier to deal with.

Thoughts?

Again, thanks for all the help.

 
JohnS
Guru

Joined: 18/11/2011
Location: United Kingdom
Posts: 3998
Posted: 02:45am 04 Jul 2014
Copy link to clipboard 
Print this post

Or

X = VAL("&H" + A$)
PRINT #1, CHR$(X);

John
 
viscomjim
Guru

Joined: 08/01/2014
Location: United States
Posts: 925
Posted: 03:08am 04 Jul 2014
Copy link to clipboard 
Print this post

I like that JohnS, a bit neater. Thanks!!!
 
MicroBlocks

Guru

Joined: 12/05/2012
Location: Thailand
Posts: 2209
Posted: 03:47am 04 Jul 2014
Copy link to clipboard 
Print this post

or

Define a function:
[code]
Function CharFromHex$(value$)
IF LEFT(value$,2) <> "&H" THEN
CharFromHex$ = CHR$(VAL("&H" + value$))
ELSE
CharFromHex$ = CHR$(VAL(value$))
ENDIF
END FUNCTION
[/code]

The use it like:
[code]
input A$
PRINT #1, CharFromHex$(A$)
[/code]

Microblocks. Build with logic.
 
viscomjim
Guru

Joined: 08/01/2014
Location: United States
Posts: 925
Posted: 05:11am 05 Jul 2014
Copy link to clipboard 
Print this post

Thanks TZA, thats a good one too.... module is making noise. Lots of fun with this one...
 
     Page 2 of 2    
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025