Hello,
I want to save data to sd card file 'log.dat' as follows: CardID,UserName,Date_Time(hh:mm:ss,yy/mm/dd)
Date_Time components are public variables from timer sub, CardID and UserNameare sent from asyncstream. savelog sub called from ReadRFID stream.
Thanks
	
	
	
	
	
	
	
		
			
			
			
			
			
		
	
	
	
		
	
	
		
	
	
	
	
	
	
	
	
		
			
			
			
			
			
		
	
	
	
		
	
	
		
	
	
	
	
	
	
	
	
		
			
			
			
			
			
		
	
	
	
		
	
	
		
	
			
			I want to save data to sd card file 'log.dat' as follows: CardID,UserName,Date_Time(hh:mm:ss,yy/mm/dd)
Date_Time components are public variables from timer sub, CardID and UserNameare sent from asyncstream. savelog sub called from ReadRFID stream.
Thanks
			
				B4X:
			
		
		
		Sub DS1320timer_Tick()
    'The current time must be defined in the sub. The global can not be used.
    Dim currenttime As DSTime
    currenttime = DS1302.CurrentTime
 
     Years = currenttime.years
     Months = currenttime.Months
     DayOfMonth = currenttime.DayOfMonth
     Hours = currenttime.Hours
     Minutes = currenttime.Minutes
     Seconds = currenttime.Seconds
     DayOfWeek = currenttime.DayOfWeek
  
End Sub
			
				B4X:
			
		
		
		private Sub ReadRFID(Buffer() As Byte)
    Dim tmpBuffer () As Byte
    Dim Str_HexNumber As String
    Dim Card_Number As ULong
    'Log(BC.HexFromBytes(Buffer))
    If BC.ArrayCompare(Buffer,BufferLast) = 0 Then 'compare last read card to recent one
        Return
    End If
  
    tmpBuffer= BC.SubString2(Buffer,3,11) 'get 8 bytes only, not whole 10 card bytes, filing system supports 8.3 format that is enogh to get more than 999 999 999 , get ride of checksum and start byte
    Str_HexNumber = BC.StringFromBytes(tmpBuffer)
    Card_Number = Bit.ParseInt(Str_HexNumber, 16) 'convert hex to decimal string
    Log(Card_Number)
    BC.ArrayCopy(Buffer,BufferLast)                    'copy last read to recent one, for next comparison              
    NoReadingTimerTicks = 0
   Savelog(Card_Number,"Mostez") 'name is hard coded for testing just for now
End Sub
			
				B4X:
			
		
		
		private Sub Savelog(Card_Number As ULong,UserName As String)
    Dim Buffer() As Byte
    'how can I load card number, time elements, and string into array
   
    If Sd.OpenReadWrite ("log.dat") = True Then
        Sd.Stream.WriteBytes(Buffer,0,Buffer.Length)
    End If
End Sub 
				 
 
		 
 
		 
 
		 
 
		