Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

sending a string of HEX via serial port.
Goto page Previous  1, 2
 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    www.mcselec.com Forum Index -> BASCOM-AVR Archive
View previous topic :: View next topic  
Author Message
Beke

Bascom Member



Joined: 14 Feb 2008
Posts: 45

hungary.gif
PostPosted: Mon Mar 31, 2008 8:25 pm    Post subject: Reply with quote

Hi,
the point of my code example was to show that Bascom treats the Chr(0) as an exception. It does not take into consideration when computing the length of a string, nor stops printing when arriving it. The output of the code is (in simulation):
ABCD
4
I don't know whether other language idioms implement the Chr(0) with strings and Print in another way. Maybe. An oscilloscope would show, whether the Chr(0) "comes out" or not. I guess it doesn't, for already the string is shorter than 5.
Back to top
View user's profile
Beke

Bascom Member



Joined: 14 Feb 2008
Posts: 45

hungary.gif
PostPosted: Mon Mar 31, 2008 8:30 pm    Post subject: Reply with quote

Hi,
the point of my code example was to show that Bascom treats the Chr(0) as an exception. It does not take into consideration when computing the length of a string, nor stops printing when arriving it. The output of the code is (in simulation):
ABCD
4
I don't know whether other language idioms implement the Chr(0) with strings and Print in another way. Maybe. An oscilloscope would show, whether the Chr(0) "comes out" or not. I guess it doesn't, for already the string is shorter than 5.
Back to top
View user's profile
Pixelfrank

Bascom Member



Joined: 10 Dec 2005
Posts: 15
Location: Oranienburg

germany.gif
PostPosted: Tue Apr 01, 2008 10:17 am    Post subject: Reply with quote

Hi Beke,
i try your example in real.
The results are the same as in simulation.
The Null in the middle is not visible (ignored) on the Output.
Code:
  Dim A As String * 5
  A = Chr(65) + Chr(66) + Chr(67) + Chr(0) + Chr(68)
  Print A
  Print Len(a)
  Wait 1
  End
   

Important is the "wait" or "do : loop" just before the "end". Otherwise the CPU ending work also on the Uart and only "ABC" are seen on the output @ 9600 Baud.

Hi DToolan,
i found out, that the "Printbin" is usefull for my application.
I use it as follow:
Code:
Printbin 0 ; 0 ; 0 ; 0 ; 0 ; 1 ; 70 ; 70 ; 48 ; 48 ; 2;

In this form it is a bit more "eyefriendly"

Thanks for your support!

Regards
Frank
Back to top
View user's profile
Arera

Bascom Member



Joined: 23 Sep 2007
Posts: 386
Location: Wuppertal, Germany

germany.gif
PostPosted: Tue Apr 01, 2008 10:48 am    Post subject: Reply with quote

Hi,
in order to send/receive DATA (not Strings) it is useful NOT to mess around with strings, but with arrays. I have a ISM-Band transmission working with this code:
(only transmission-part is shown)

dim message(8) as byte

Sub Send_message

Message(1) = High(ident_nr) 'assign the message byte with data
Message(2) = Ident_nr
Message(3) = Adresse
Message(4) = Unit_status
Message(5) = G_sensor_alarm_cnt
Message(6) = Mk_lf_alarm_cnt
Message(7) = Tamper_alarm_cnt
Message(8) = Crc8(message(1) , 7) 'create checksum

Printbin &H0F 'Startbyte, triggers the receiver

For N = 1 To 8
Printbin Message(n) ; 1 'watch the "1": without it the hohle array is beeing send '
While Ucsra.txc = 0 : Wend 'wait until print is done
Ucsra.txc = 1
Waitms 1 'Pause for my receiver
Next N

End Sub

Itīs no problem to send data with the value "0".
Back to top
View user's profile
DToolan

Bascom Member



Joined: 14 Aug 2004
Posts: 1384
Location: Dallas / Fort Worth, Texas (USA)

blank.gif
PostPosted: Tue Apr 01, 2008 11:15 am    Post subject: Reply with quote

Finally someone who understands the non-importance of strings!
Back to top
View user's profile Yahoo Messenger
Arera

Bascom Member



Joined: 23 Sep 2007
Posts: 386
Location: Wuppertal, Germany

germany.gif
PostPosted: Tue Apr 01, 2008 11:40 am    Post subject: Reply with quote

Hi D!
I just joined the Anti-String Coalition. After having done the first 10 steps in your cool programm, can I be graded an officer? Or do I really have to climb the last two steps? Maybe inreasing my (already high) donation can help....

_________________
Just say NO to Strings! Join the Anti-String Coalition and do the 12 step program.
Visit www.justsayno2strings.com today (donations accepted)
Back to top
View user's profile
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    www.mcselec.com Forum Index -> BASCOM-AVR Archive All times are GMT + 1 Hour
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum