View previous topic :: View next topic |
Author |
Message |
hallo2
Joined: 02 Apr 2015 Posts: 2
|
Posted: Thu Apr 02, 2015 10:25 am Post subject: changing File attributes |
|
|
Hi,
i would like to change the file attribute of a file (read/write access, this is used to enable / disable wifi of an wifi sd card)
in the avr-dos library there only seems to be the command getattr to read the byte - is there a way to write it too ?
I looked in the library but i do not really understand what is going on there
Code: | [_GetAttr]
$EXTERNAL _GetDirEntry , _GetFileAttribute , _SearchDirEntry
_GetAttr:
.OBJ 93FF
.OBJ 93EF
rcall _SearchDirEntry_CheckFileName
rjmp _GetAttr1
_GetAttr0:
.OBJ 93FF
.OBJ 93EF
rcall _GetDirEntry_0
_GetAttr1:
.OBJ 91AF
.OBJ 91BF
brcc _GetAttr2
.OBJ 2788
.OBJ 938C
.OBJ 9508
_GetAttr2:
rjmp _GetFileAttribute
[end] |
Thanks,
Daniel |
|
Back to top |
|
|
albertsm
Joined: 09 Apr 2004 Posts: 5913 Location: Holland
|
Posted: Thu Apr 02, 2015 11:39 am Post subject: |
|
|
this code is used by the GETATTR() function.
There is no SETATTR. Maybe Josef can have a look at it? _________________ Mark |
|
Back to top |
|
|
hallo2
Joined: 02 Apr 2015 Posts: 2
|
Posted: Thu Apr 02, 2015 11:51 am Post subject: |
|
|
Hi,
yes i know that.
If i understood what happens in the getattr i was wondering if i can write an setattr
but i don't understand it
Thanks for the help |
|
Back to top |
|
|
albertsm
Joined: 09 Apr 2004 Posts: 5913 Location: Holland
|
Posted: Thu Jun 04, 2015 12:07 pm Post subject: |
|
|
Josef has added setattr.
it will be in the next update.
if you want to test it, write to support. do not forget to supply serial.
here is a preview of the code :
Code: |
'------------------------------------------------------------------------------
' simulate-AVR-DOS.bas
' simulate AVR-DOS using virtual XRAM drive
'
'------------------------------------------------------------------------------
$regfile = "M128def.dat"
$crystal = 16000000
' Adjust HW Stack, Soft-Stack and Frame size to 128 minimum each!!!
$hwstack=128 : $swstack=128 : $framesize=128
$xramsize = &H10000 'specify 64KB of XRAM for the file system
$sim 'for simulation only !
$baud = 19200
Config Clock = Soft
Enable Interrupts
Config Date = Mdy , Separator = dot
Dim Btemp1 As Byte ,battr1 as Byte, battr2 as Byte
$include "Config_XRAMDrive.bas" ' Does drive init too
$include "Config_AVR-DOS.BAS"
Print "Wait for Drive"
If Gbdriveerror = 0 Then
Print "Init File System ... ";
Btemp1 = Initfilesystem(1) ' Partition 1
' use 0 for drive without Master boot record
If Btemp1 <> 0 Then
Print "Error: " ; Btemp1 ; " at Init file system"
Else
Print " OK"
Print "Filesystem: " ; Gbfilesystem
Print "FAT Start Sector: " ; Glfatfirstsector
Print "Root Start Sector: " ; Glrootfirstsector
Print "Data First Sector: " ; Gldatafirstsector
Print "Max. Cluster Nummber: " ; Glmaxclusternumber
Print "Sectors per Cluster: " ; Gbsectorspercluster
Print "Root Entries: " ; Gwrootentries
Print "Sectors per FAT: " ; Glsectorsperfat
Print "Number of FATs: " ; Gbnumberoffats
End If
Else
Print "Error during Drive Init: " ; Gbdriveerror
End If
Dim strDummy as String * 12
Dim Datei As String * 12 , Attribut As Byte
Datei = "Test1.txt"
Open Datei For Output As #11
Print #11 , "Testzeile1"
Close #11
open "Test2.txt" For output as #11
Print #11, "Testzeile2"
close #11
open "Test3.txt" for output as #11
Print #11, "Testzeile3"
close #11
' Set readonly Bit in Test1.txt
Attribut = &B00000001
Setattr Datei , Attribut
' Reset Archib-Bit in test1.txt
Attribut = &B00100000
clearattr Datei , Attribut
' Check for Filename with wildcard, which is not supported
' Set readonly Bit in Test1.txt
Datei = "Test*.txt"
Attribut = &B00000001
Setattr Datei , Attribut
Print gbDOSError
Datei = DIR("Test*.txt")
Attribut = &B00000001
while Datei > ""
SetAttr Attribut
Datei = DIR()
wend
Datei = DIR("Test*.txt")
Attribut = &B00100000
While Datei > ""
battr1=Getattr()
clearattr Attribut
battr2=Getattr()
print datei ;" "; battr1;" " ; battr2
Datei = DIR()
wend
End |
_________________ Mark |
|
Back to top |
|
|
mmarlette
Joined: 30 Nov 2007 Posts: 311 Location: Delano, MN
|
Posted: Thu Jun 04, 2015 2:29 pm Post subject: |
|
|
Very nice!
Thank you Josef and Mark for GREAT products and exceptional support!!!
Mark- For ones that purchased an AVR-DOS commercial license, how do we get the updated source? SLA, support, DL page?
Regards,
Mark |
|
Back to top |
|
|
albertsm
Joined: 09 Apr 2004 Posts: 5913 Location: Holland
|
Posted: Thu Jun 04, 2015 3:31 pm Post subject: |
|
|
We update the package with a new update of bascom. so when you have registered at register.mcselec.com you can download it from there.
We post a news topic on the mcs homepage when a package is updated. _________________ Mark |
|
Back to top |
|
|
|