Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 06:49 06 Jul 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 : Serial Communication help

Author Message
KRZ3
Newbie

Joined: 31/12/2014
Location: United States
Posts: 38
Posted: 03:47am 10 Oct 2016
Copy link to clipboard 
Print this post

I have situation where I use a unique qualifying number that changes often depending on which radio I'm talking to. My own network setup in a way. The problem is with this radio I can't get it to send a string and can only send ASCII or CHR$ data.

Is there an easy way to do the following.

Micromite one sends

ID=855

For example normally I do

Print #1,ID$+ chr$(12)+chr$(3)+ chr$(4)

Is there a easy way to break out 855 as chr$(8) + chr$(5) + chr$(5) and send the data?

Print #1,+ chr$(8)+chr$(5)+ chr$(5)+ chr$(12)+chr$(3)+ chr$(4)

Micromite 2

The receiver gets the data and puts the first 3 characters back together as the string 855 and then reads the ID so it knows if it should process the next 3 bytes?

Thanks for any help.

 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9588
Posted: 04:11am 10 Oct 2016
Copy link to clipboard 
Print this post

When you say the radio module can't send strings, does that mean that you can only send data one byte at a time?

This would be unusual, but not impossible I guess.
What RF module are you using?

Most "Smart" RF modules will have some kind of input buffer of at least a handful of bytes or so, which should happily accept a string - provided it is not too long, naturally.

So-called "Dumb" modules will send data continuously if you send it to them - they simply don't care and will transmit whatever you throw at them. All checksum and any other data checking is left totally up to you.


Smoke makes things work. When the smoke gets out, it stops!
 
JohnS
Guru

Joined: 18/11/2011
Location: United Kingdom
Posts: 4036
Posted: 04:53am 10 Oct 2016
Copy link to clipboard 
Print this post

If you mean a 3-character ID, you could do

ID$="855"

Print #1,ID$ + chr$(12)+chr$(3)+ chr$(4)

Or just
Print #1,"855" + chr$(12)+chr$(3)+ chr$(4)

(those others are CTRL+L, CTRL+C, CTRL+D, or FF, ETX, EOT - just checking they're what you mean)

ASCII digit (printable) 8 would be chr$(56) not chr$(8), but it's a lot more understandable (often called "readable") as a string i.e. in quotes.

JohnEdited by JohnS 2016-10-11
 
KRZ3
Newbie

Joined: 31/12/2014
Location: United States
Posts: 38
Posted: 05:27am 10 Oct 2016
Copy link to clipboard 
Print this post

I have an email into the company asking them why it won't send the string. It's not a length issue as I can send the same data string and it will work.

If I send this it works

Print #1,+ chr$(8)+chr$(5)+ chr$(5)+ chr$(12)+chr$(3)+ chr$(4)

If I send this it won't work
Print #1,"855" + chr$(12)+chr$(3)+ chr$(4)

That's why I was looking for a an easy way to covert the string and then reassemble when received. I never had this issue before with other radios.

The radio is the http://www.multitech.com/brands/multiconnect-mdot

It's setup in Peer to peer mode.
 
JohnS
Guru

Joined: 18/11/2011
Location: United Kingdom
Posts: 4036
Posted: 05:45am 10 Oct 2016
Copy link to clipboard 
Print this post

If the first works then of course the other will not, due to ASCII encoding.

In ASCII the printable 8 has value 56 (all printable digits are offset by 48).

Print #1,"855" + ...
is thus the same as
Print #1,chr$(56)+chr$(53)+chr$(53) + ...

Don't be surprised if they reply basically telling you to look at ASCII.

JohnEdited by JohnS 2016-10-11
 
KRZ3
Newbie

Joined: 31/12/2014
Location: United States
Posts: 38
Posted: 06:15am 10 Oct 2016
Copy link to clipboard 
Print this post

Hey John,

Thanks for the help. I apologize as I know I'm not explaining this well. I don't know the data formats and sending well at all.

I will try and explain the sequence of events.

Type on a keypad 855 or whatever 3 digit number.
so now the ID=855


I don't care what 855 looks like in ASCII or what the real value is.

I'm wondering if there is a way to separate and send individually

Print #1,+ chr$(8)+chr$(5)+ chr$(5) and then on the receiving end put it back in the same string format as 855. Unless the conversion will mess it up.

I basically need a way to send a 3 digit code and receive the same three digit code.

 
JohnS
Guru

Joined: 18/11/2011
Location: United Kingdom
Posts: 4036
Posted: 06:26am 10 Oct 2016
Copy link to clipboard 
Print this post

Something like
ID3 = ID % 10
ID = (ID - ID3) / 10
ID2 = ID % 10
ID = (ID - ID2) / 10
ID1 = ID % 10 'if 3-digit, not needed, can just use ID1 = ID

Print #1, chr$(ID1) + chr$(ID2) + chr$(ID3) + ...

% is modulus i.e. remainder on division
so ID % 10 is the bottom (decimal) digit of ID

JohnEdited by JohnS 2016-10-11
 
Phil23
Guru

Joined: 27/03/2016
Location: Australia
Posts: 1667
Posted: 10:03am 10 Oct 2016
Copy link to clipboard 
Print this post

Don't quite understand the purpose of the string you are trying to send.
In particular the last 3 ASCII characters.

FF ETX EOT

And also, the string being sent will end with CR LF.

But Try a few things at the command prompt.

[Code]> dim id$ as string
>
> id$="855"
> print ID$
855
> print ID$+Chr$(12)+Chr$(3)+Chr$(4)
855 
>
[/code]

It actually shows up differently on the screen, as far as the 3 low order characters go.



Why are you trying Chr$(8) 5 5 etc wouldn't this be correct?

[Code]> print Str$(8)+Str$(5)+Str$(5)+Chr$(12)+Chr$(3)+Chr$(4)
855 
>
[/code]

As far as stripping out the digits is concerned, something like this would work,

[Code]print id$
855
> print mid$(id$,1,1) : Print mid$(id$,2,1) : Print mid$(id$,3,1)
8
5
5
>
[/code]

Phil
 
KRZ3
Newbie

Joined: 31/12/2014
Location: United States
Posts: 38
Posted: 03:58am 11 Oct 2016
Copy link to clipboard 
Print this post

Thanks Phil,

Some good ideas to try.
 
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