Embedded Software

Embedded Software

Topics related to SCADE Suite, SCADE Display, SCADE One and more.

Access Violation

    • yair.oros
      Subscriber
      Hey! have a good day.
       
      I am trying to create a function in suite that reads a number from a file and then just put it in a variable. I wish to increase this until read information of a flight but I am doing test first with a number.
       
      I achieved create the imported function that contains code C, instantiated in the function of suite. It build and simulates but when I will try to start the simulation a pop-up window show: "An exception has occurred: access violation" I think is for the "fopen" in my code, but I wish to know if there are some way to take this data from a document.
      Please could someone helps me?
       
      I add here my c code and the imported function instantiated in suite.
      Instantiate Function
      My code for read a number from a file
    • Romain Andrieux
      Ansys Employee

      Hello,

       

      In your situation, you are using format string "%d" which will read an int; however numActual is of type kcg_int8 which is by default a 'char', causing an Access Violation (since you are trying to write 32bits into 8bits) when perfoming the fscanf. To fix it you can change the string formating to "%c". 

      Hope this helps.

       

      Best Regards

      Romain

    • yair.oros
      Subscriber

      Thanks! the observation were really useful, and guide me to change the return in my function a cast with the int value.

Viewing 2 reply threads
  • You must be logged in to reply to this topic.