Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

Send String over USB instead Byte

 
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-AVR
View previous topic :: View next topic  
Author Message
katipefendi

Bascom Member



Joined: 24 Oct 2013
Posts: 30

blank.gif
PostPosted: Sun Mar 11, 2018 3:16 am    Post subject: Send String over USB instead Byte Reply with quote

Hallo,

it is possible send string over usb instead Byte with usb.inc file?


Code:

Sub Hid_task()
 If Usb_connected = 1 Then ' Check USB HID is enumerated
 Usb_select_endpoint Ep_hid_out ' Get Data Repport From Host
 If Ueintx.rxouti = 1 Then ' Is_usb_receive_out())
 Dummy1 = Uedatx : Print "Got : " ; Dummy1
 Dummy2 = Uedatx : Print "Got : " ; Dummy2
 Dummy = Uedatx : Print "Got : " ; Dummy
 Dummy = Uedatx : Print "Got : " ; Dummy
 Dummy = Uedatx : Print "Got : " ; Dummy
 Dummy = Uedatx : Print "Got : " ; Dummy
 Dummy = Uedatx : Print "Got : " ; Dummy
 Dummy = Uedatx : Print "Got : " ; Dummy
 Usb_ack_receive_out
 End If
 
 If Dummy1 = &H55 And Dummy2 = &HAA Then ' Check if we received DFU mode command from host
 Usb_detach ' Detach Actual Generic Hid Application
 Waitms 500
 Goto &H1800 'goto bootloader
 'here you could call the bootloader then
 End If
 
 Usb_select_endpoint Ep_hid_in ' Ready to send these information to the host application
 If Ueintx.txini = 1 Then ' Is_usb_in_ready())
 Uedatx = 1
 Uedatx = 2
 Uedatx = 3
 Uedatx = "Here i want send Text"                           '<-- for example!!! is it possible??
 Uedatx = 5
 Uedatx = 6
 Uedatx = 7
 Uedatx = 8
 Usb_ack_fifocon ' Send data over the USB
 End If
 End If
End Sub
 

 


(BASCOM-AVR version : 2.0.8.0 , Latest : 2.0.8.1 )
Back to top
View user's profile
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 5056
Location: Holland

blank.gif
PostPosted: Mon Mar 12, 2018 10:11 am    Post subject: Reply with quote

you can send strings since these are just bytes terminated with a zero byte.
for example :
Code:
total_length=len(somestring) + 1
for j=1 to total_length
  Uedatx = asc(somestring, J)  'get byte from string and send it
next
 

you should however take in mind the length of the end point. in the sample it is 8. so to keep it working the string length is limited to 7.
the next step would be to send multiple packets. and/or to use bigger end points.

_________________
Mark
Back to top
View user's profile Visit poster's website
katipefendi

Bascom Member



Joined: 24 Oct 2013
Posts: 30

blank.gif
PostPosted: Sat Mar 17, 2018 1:51 am    Post subject: Solved Reply with quote

Hallo,

i have solved with this method, it works very well.

Code:

 Usb_select_endpoint Ep_hid_in                         ' Ready to send these information to the host application

      If Ueintx.txini = 1 Then                              ' Is_usb_in_ready())
         Uedatx = Ausgang1
         Uedatx = Ausgang2
         Uedatx = Ausgang3
         Uedatx = 0
         Uedatx = 0
         Uedatx = 0
         Uedatx = 0
         Uedatx = 0

         Uedatx = Deviceadresse
         Uedatx = Devicetype
         Uedatx = 0                        
         Uedatx = Timeout                      
         Uedatx = 3                                        
         Uedatx = 0
         Uedatx = 0
         Uedatx = 0

         Uedatx = 20
         Uedatx = 18
         Uedatx = 03
         Uedatx = 17
         Uedatx = 01
         Uedatx = 0
         Uedatx = 0
         Uedatx = 0

         Uedatx = 0
         Uedatx = 0
         Uedatx = 0
         Uedatx = 0
         Uedatx = 0
         Uedatx = 0
         Uedatx = 0
         Uedatx = 0

         Usb_ack_fifocon                                    ' Send data over the USB

      End If
 


BR
Sinan
Back to top
View user's profile
Display posts from previous:   
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-AVR All times are GMT + 1 Hour
Page 1 of 1

 
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